Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Displaying records on Wordpress Blog

 

 


mel
User

Aug 16, 2011, 8:00 AM

Post #1 of 10 (1688 views)
Shortcut
Displaying records on Wordpress Blog Can't Post

Is it possible to display records on a page of a blog?

All of my sites are on same server under my control
I am able to disable open_basedir without problem

The code below is what I use on several conventional coded websites not wordpress and all works fine

If I try and use the same code it just shows the code and does not display any record detail

<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/melsview/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($biosRecords, $biosMetaData) = getRecords(array(
'tableName' => 'bios',
'allowSearch' => '0',
'where' => 'region = "east anglia"',

));

?>

Do I need to change something or is it the case that you cannot display records from the cms database on a blog?

Thanks - Mel


robin
User / Moderator


Aug 16, 2011, 4:57 PM

Post #2 of 10 (1681 views)
Shortcut
Re: [mel] Displaying records on Wordpress Blog [In reply to] Can't Post

Hey Mel,

Are you trying to display the records by pasting that code into a wordpress article? For security reasons, wordpress wont allow php code to execute. You'll need to pull the records in some other way, maybe in the wordpress template.

Hope that helps,
Robin


mel
User

Aug 17, 2011, 1:21 AM

Post #3 of 10 (1679 views)
Shortcut
Re: [robin] Displaying records on Wordpress Blog [In reply to] Can't Post


In Reply To
Hey Mel,

Are you trying to display the records by pasting that code into a wordpress article? For security reasons, wordpress wont allow php code to execute. You'll need to pull the records in some other way, maybe in the wordpress template.

Hope that helps,
Robin


Hi Robin,

Yes was pasting the code into a page, so what you are suggesting is putting the code directly into the template that wordpress uses to display a specific page?

Mel


robin
User / Moderator


Aug 17, 2011, 9:22 AM

Post #4 of 10 (1659 views)
Shortcut
Re: [mel] Displaying records on Wordpress Blog [In reply to] Can't Post

Hey Mel,

You'll need to put the code anywhere will it will actually execute. That should work directly in the template. Or maybe you can use an iframe.

Hope that helps,
Robin


mel
User

Nov 12, 2011, 4:34 AM

Post #5 of 10 (1540 views)
Shortcut
Re: [robin] Displaying records on Wordpress Blog [In reply to] Can't Post

Hi,

The following code works in a template but throws up errors

A blank template page .i.e before I drop in database query code, displays without errors

This code is the same code that works without problem on non wordpress sites any ideas how to get rid of the error messages?



Code:

<?php
/*
Template Name: Snarfer2
*/
?>


This is the snarfer2 template with old css taken out

<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/melsview/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($biosRecords, $biosMetaData) = getRecords(array(
'tableName' => 'bios',
'where' => 'tw1=1',
));

?>


<div>

<div><h2>Heading</h2></div>


<!-- start of gallery layout -->
<div>

<?php foreach ($biosRecords as $biosRecord): ?><!-- master foreach-->
<div>
<div>
<h2><?php echo $biosRecord['name'] ?>&nbsp;&nbsp;Age: <?php echo $biosRecord['age'] ?></h2>
</div>



<div align="center"><?php foreach ($biosRecord['newimage'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<a href="<?php echo $biosRecord['_link'] ?>" target="_self"><img src="<?php echo get_custom_watermark_url($upload['urlPath'], 'testwater.gif') ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo $biosRecord['name'] ?>"></a>
<?php else: ?>
<?php endif ?>
</div>
<?php endforeach ?>

<p align="center"><a href="<?php echo $biosRecord['_link'] ?>" target="_self">Click to view details</a></p>

<!-- end viewme--></div>

<!-- finish master foreach--><?php endforeach ?>

<!-- end regionGallery --></div>
<!-- end of gallery layout -->
<!-- end wrapperMain --></div>


Error Messages:


Strict Standards: Non-static method GA_Filter::widget_content() cannot be called statically in /home/melhud/public_html/wp-includes/plugin.php on line 170 Strict Standards: Non-static method GA_Filter::widget_content() cannot be called statically in /home/melhud/public_html/wp-includes/plugin.php on line 170 Strict Standards: Non-static method GA_Filter::widget_content() cannot be called statically in /home/melhud/public_html/wp-includes/plugin.php on line 170

And These error messages appear at the bottom of the page:

Strict Standards: is_a(): Deprecated. Please use the instanceof operator in /home/melhud/public_html/wp-includes/script-loader.php on line 660

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/user.php on line 660

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/user.php on line 660

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/class-wp-admin-bar.php on line 167

Strict Standards: Only variables should be passed by reference in /home/melhud/public_html/wp-includes/admin-bar.php on line 266

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/class-wp-admin-bar.php on line 167

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/class-wp-admin-bar.php on line 167

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/class-wp-admin-bar.php on line 167

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/class-wp-admin-bar.php on line 167

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/class-wp-admin-bar.php on line 167

Strict Standards: Creating default object from empty value in /home/melhud/public_html/wp-includes/class-wp-admin-bar.php on line 167


Jason
Staff / Moderator


Nov 13, 2011, 9:16 PM

Post #6 of 10 (1529 views)
Shortcut
Re: [mel] Displaying records on Wordpress Blog [In reply to] Can't Post

Hi,

All of this warning are coming from files inside the wp-includes folder, which look like wordPress plugins.

It seems that the code in those files don't follow PHP strict standards and your server is set up to report strict standards errors/warnings. You should be able to turn this off with this code up near the top of your page:


Code
error_reporting(E_ALL ^ E_STRICT);


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


mel
User

Nov 14, 2011, 12:54 AM

Post #7 of 10 (1513 views)
Shortcut
Re: [Jason] Displaying records on Wordpress Blog [In reply to] Can't Post

Hi Jason,

Thanks for your reply

Do you mean that this piece of code should be placed on the template page that I have set up?

Also do I have to put any php command around the text or just put it on the page as it is

Thanks
Mel


Jason
Staff / Moderator


Nov 14, 2011, 10:07 AM

Post #8 of 10 (1406 views)
Shortcut
Re: [mel] Displaying records on Wordpress Blog [In reply to] Can't Post

Hi,

The code in those files are getting executed, they're just producing warnings, which is what you're seeing on your page.

Try this at the very top of your file:



Code
<?php error_reporting(E_ALL ^ E_STRICT); ?>


Let us know if that takes care of the issue for you.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


mel
User

Nov 14, 2011, 12:15 PM

Post #9 of 10 (1395 views)
Shortcut
Re: [Jason] Displaying records on Wordpress Blog [In reply to] Can't Post

Hi Jason,

I have put the line of code in the template that I am using for the page but it has added error messages to the top of the page as well know... along the same lines as the other error messages

Couple of thoughts although I am no expert on this

1. Is there a way of setting up something in an .htaccess file to deal with it it

OR

2. Could I make a connection to the external database using mysql connect database username etc, although I am not sure how I would code this to pull up what it is already displaying, or if it would make any difference

Both sites are on the same server which I have full control of and I can allow other domains to connect to the database through Cpanel

Thanks
Mel


Jason
Staff / Moderator


Nov 14, 2011, 8:22 PM

Post #10 of 10 (1374 views)
Shortcut
Re: [mel] Displaying records on Wordpress Blog [In reply to] Can't Post

Hi Mel,

The problem seems to be the error reporting level of your server. It shouldn't have anything to do with your database connection. If you want to fill out a 2nd Level Support Request we can take a quick look at it for you. Although, since the errors seem to be coming from 3rd Party scripts I can't guarantee that this can be handled through support.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/