jo.nova Posted August 5, 2008 Share Posted August 5, 2008 Hi, Can anyone find something wrong with this statement? //store the current section id $secNum = $secResult[$i]->id; //check value echo "Section: " . $secNum . "<br /><br />"; //set query $sql = "SELECT * FROM #__categories WHERE section = $secNum GROUP BY id ORDER BY ordering"; //get results $database->setQuery($sql) or die ('Could not set category query'); $catResult = $database->loadObjectList() or die ('Could not load category object list'); It fails every time. Here's the output: Section: 1 Could not set category query The statement runs fine when run through phpMyAdmin, except I have tweak the table prefixes because of the DB object abstraction. Any ideas? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 5, 2008 Share Posted August 5, 2008 why not error check the query <?php //store the current section id $secNum = $secResult[$i]->id; //check value echo "Section: " . $secNum . "<br /><br />"; //set query $sql = "SELECT * FROM #__categories WHERE section = $secNum GROUP BY id ORDER BY ordering"; //get results $database->setQuery($sql) or die (mysql_error()."<br /><br />".$sql); $catResult = $database->loadObjectList() or die ('Could not load category object list'); It fails every time. Here's the output: Section: 1 Could not set category query The statement runs fine when run through phpMyAdmin, except I have tweak the table prefixes because of the DB object abstraction. Any ideas? Quote Link to comment Share on other sites More sharing options...
jo.nova Posted August 5, 2008 Author Share Posted August 5, 2008 Well, first of all, I'm not an expert, so some more specific error checking advice would be appreciated. How would I use mysql_error() if I'm building queries and feeding them to a database object, instead of talking directly to the database? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 6, 2008 Share Posted August 6, 2008 Well, first of all, I'm not an expert, so some more specific error checking advice would be appreciated. How would I use mysql_error() if I'm building queries and feeding them to a database object, instead of talking directly to the database? I'm not sure what you mean... but can we see the error? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.