Xtrapositive Posted May 20, 2012 Share Posted May 20, 2012 Hi guys , can someone help me with this code its giving me "query was empty Error" its connecting but...? and please find attached the entire php page for clarity. Thanks . <?php //connect database require_once "connect_to_mysqli.php"; //query the datbase $sqlcommand = "SELECT post_id, title, body From posts ORDER by post_id desc"; $query = mysql_query($sqlCommand) or die (mysql_error()); while($row = mysql_fetch_array($query)) { $title = $row["title"]; echo "<h3>$title</h3>"; } // Free the result set if it is large mysql_free_result($query); // close mysql connection mysql_close(); ?> 18406_.txtFetching info... Link to comment https://forums.phpfreaks.com/topic/262817-query-was-empty/ Share on other sites More sharing options...
trq Posted May 20, 2012 Share Posted May 20, 2012 $sqlCommand is not defined anywhere in your code. Link to comment https://forums.phpfreaks.com/topic/262817-query-was-empty/#findComment-1346986 Share on other sites More sharing options...
fenway Posted May 20, 2012 Share Posted May 20, 2012 error_reporting(E_STRICT) is your friend. Link to comment https://forums.phpfreaks.com/topic/262817-query-was-empty/#findComment-1347033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.