mike12255 Posted April 15, 2011 Share Posted April 15, 2011 Hey guys I cant seem to find this error guess ive been looking at this screen to long to try and get this project done in time would appriciate if someone could take a fresh look at it and tell me where I went wrong. Basically im trying to get the number of entries returned by my query. I echoed out the query and manually entered it into phpmyadmin there is a 1 row result however whenever i kill $num_result it doesnt give me any output. <?php public function getNewMessages() { global $db,$db_table_prefix; $sql = "SELECT * FROM messages WHERE `to_id` = '".$db->sql_escape($this->user_id)."' AND `read` = 0"; $res = mysql_query($sql) or die (mysql_error()); $num_rows = mysql_num_rows($res); die ($num_rows); // does not return a value return $num_rows; } ?> Link to comment https://forums.phpfreaks.com/topic/233773-num_rows-problem/ Share on other sites More sharing options...
btherl Posted April 15, 2011 Share Posted April 15, 2011 From the manual page of exit(), for which die() is an alias: If status is an integer, that value will be used as the exit status and not printed. Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully. In other words, use something other than die() to print out the number of rows. Link to comment https://forums.phpfreaks.com/topic/233773-num_rows-problem/#findComment-1201853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.