I have been reading my wordpress database using this snippet, and some strange behaviour is occurring that I cant understand.
$wordpress = '';
// set the options for the query
$host="localhost";
$user="username";
$pass="password";
$dbase="`database name`";
$fields="*";
$from="wp_posts";
$where="post_status='publish' AND post_type='post'";
$sort="post_date";
$dir="DESC";
$limit=1;
$push=true;
// run the query
$results = $etomite->getExtTableRows($host,$user,$pass,$dbase,$fields,$from,$where,$sort,$dir,$limit,$push);
if($results)
{
foreach ($results as $post)
{
$wordpress .= '<h3><a href="'.$post['guid'].'" title="'.$post['post_title'].'">'.$post['post_title'].'</a></h3>';
$wordpress .= '<p>'.$post['post_excerpt'].'<br /><small>Posted '.$post['post_date'].'. Comments '.$post['comment_count'].'. <a href="'.$post['guid'].'" title="'.$post['post_title'].'">Read More</a></small></p>';
}
}
else
{
$wordpress .= 'No posts found';
}
return $wordpress;
In the manager window, the page is fine and everything is working, but when I go to the live page, there is a header being attached on the bottom of the page and an error message.
The error message is
« Error »
Etomite encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
PHP error debug
Error: Cannot modify header information - headers already sent by (output started at (removed for security)/index.php:2070)
Error type/ Nr.: Warning - 2
File: /(removed for security)/index.php
Line: 324
Line 324 source: header('Content-Type: '.$type.'; charset='.$this->config['etomite_charset']);
Parser timing
MySQL: 0.0050 s s (3 Requests)
PHP: 0.5344 s s
Total: 0.5394 s s
It looks like a new header is being pasted on the bottom of the code. I have a fresh install of 1.1 (Prelude) and when I remove the snippet the page works fine and the error dissappears.
Thank you in advance for any ideas to solve this,
Paul.
EDIT: Changed title to solved so people don't think there is anything wrong with the function or etomite.
Edited by PaulD, 18 March 2010 - 09:31 PM.











