The Little Guy Posted August 4, 2009 Share Posted August 4, 2009 OK, I am not getting my FOUND_ROWS() function to work in the following code: $_id = 1; $limit = 0; $max = 8; $sql = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM images WHERE owner = '$_id' ORDER by id DESC LIMIT $limit, $max")or die(mysql_error()); $result_count = mysql_query("SELECT FOUND_ROWS()")or die(mysql_error()); $total = mysql_fetch_array($result_count); $totalrows = $total[0]; echo $totalrows; If I were to remove the LIMIT, I would get 12 results, but $totalrows echo's out 0. What could have happened for this not to work, or am I missing something? This used to work before, but now it doesn't work, and I don't know why... Link to comment https://forums.phpfreaks.com/topic/168750-solved-sql_calc_found_rows/ Share on other sites More sharing options...
phpSensei Posted August 4, 2009 Share Posted August 4, 2009 try $_id = 1; $limit = 0; $max = 8; $sql = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM images WHERE owner = '$_id' ORDER by id DESC LIMIT $limit, $max")or die(mysql_error()); $result_count = mysql_query("SELECT FOUND_ROWS() as `found_rows`")or die(mysql_error()); $total = mysql_fetch_array($result_count); $totalrows = $total['found_rows']; echo $totalrows; Link to comment https://forums.phpfreaks.com/topic/168750-solved-sql_calc_found_rows/#findComment-890305 Share on other sites More sharing options...
The Little Guy Posted August 4, 2009 Author Share Posted August 4, 2009 hmmm.... Nope, but if I run both the queries in PHPMyAdmin, it returns the correct number of results.... If I run it in my php, I get 0... Could it be because I have Apache mod_gzip disabled and/or the output buffer = 0 in my php.ini file? Link to comment https://forums.phpfreaks.com/topic/168750-solved-sql_calc_found_rows/#findComment-890309 Share on other sites More sharing options...
phpSensei Posted August 4, 2009 Share Posted August 4, 2009 Try turning them on, and see what happens. edit: I dont see how mod_gizp would affect this, I did some research and found nothing related between the two. Turn on error_reporting and see what happens. Link to comment https://forums.phpfreaks.com/topic/168750-solved-sql_calc_found_rows/#findComment-890314 Share on other sites More sharing options...
The Little Guy Posted August 4, 2009 Author Share Posted August 4, 2009 I don't have access to the Apache configuration files, but changing the PHP ini file's output buffer to 4096, and it still doesn't work. Link to comment https://forums.phpfreaks.com/topic/168750-solved-sql_calc_found_rows/#findComment-890318 Share on other sites More sharing options...
phpSensei Posted August 4, 2009 Share Posted August 4, 2009 I just tested and I am actually getting the same problem on my server. What a small world... mod_gzip is enabled here Link to comment https://forums.phpfreaks.com/topic/168750-solved-sql_calc_found_rows/#findComment-890320 Share on other sites More sharing options...
The Little Guy Posted August 4, 2009 Author Share Posted August 4, 2009 GOT IT!! Change: mysql.trace_mode = on To: mysql.trace_mode = false in your php.ini file Link to comment https://forums.phpfreaks.com/topic/168750-solved-sql_calc_found_rows/#findComment-890325 Share on other sites More sharing options...
phpSensei Posted August 4, 2009 Share Posted August 4, 2009 GOT IT!! Change: mysql.trace_mode = on To: mysql.trace_mode = false in your php.ini file thanks man, haha should have been the other way around, but always learn something new... this is going in my notes Link to comment https://forums.phpfreaks.com/topic/168750-solved-sql_calc_found_rows/#findComment-890351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.