User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 427,097 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,328 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 655 | Replies: 16
Reply
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: MySQL num rows error

  #11  
Jul 24th, 2008
Umm.. Post the whole page.. I ll tell you what to do next..
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jul 2008
Posts: 14
Reputation: missaaliyah is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
missaaliyah's Avatar
missaaliyah missaaliyah is offline Offline
Newbie Poster

Re: MySQL num rows error

  #12  
Jul 24th, 2008
  1. <?php
  2. ini_set("max_execution_time", "30000");
  3.  
  4.  
  5. # choose a banner
  6.  
  7. include_once('../includes/db_connect.php');
  8. ?>
  9. <?php
  10. ini_set("max_execution_time", "30000");
  11.  
  12. session_start();
  13.  
  14. # remove members from the mailing list when they click from within the newsletter
  15. check_admin();
  16.  
  17.  
  18. if (isset($HTTP_GET_VARS['mode']) && $HTTP_GET_VARS['mode']=='delete') {
  19. $id=$HTTP_GET_VARS['id'];
  20. $query="DELETE FROM dir_site_list WHERE site_id = $id";
  21. $return=mysql_query($query,$link);
  22. }
  23.  
  24. $query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y'ORDER BY site_id LIMIT $start,$limit";
  25. $return=mysql_query($query);
  26. $TOTAL=mysql_num_rows($return);
  27. $sess_id="PHPSESSID=".session_id();
  28. include("$CONST_INCLUDE_ROOT/Templates/maintemplate.header.inc.php");
  29. ?>
  30.  
  31.  
  32. <?php include('../includes/admin_header.php'); ?>
  33. <?php
  34. while ($sql_array=mysql_fetch_object($return)) {
  35.  
  36. $linkback_url="http://$sql_array->site_linkback";
  37. $linkback_url=trim($linkback_url);
  38.  
  39. print("Checking:$sql_array->site_id> <a href='$linkback_url' target='blank'>$linkback_url</a>");
  40. flush();
  41. $contents="";
  42.  
  43. if (@$fp=fopen($linkback_url,'r')) {
  44. $chktime=time();
  45. while(!feof($fp))
  46. {
  47. $contents.= fread($fp,1024);
  48. if (time() >= $chktime+3) break;
  49. }
  50. fclose($fp);
  51.  
  52. if (strstr($contents,$CONST_LINK_ROOT)) {
  53. $test_result="<font color='green'>Passed</font>";
  54. } else {
  55. $test_result="<font color='red'>Failed</font> -> <a href='linkchecker.php?mode=delete&id=$sql_array->site_id&start=$start&limit=$limit'><font color='red'>[Delete]</font></a>";
  56. }
  57.  
  58. print(" -> $test_result<br>");
  59. } else {
  60. print(" -> <a href='linkchecker.php?mode=delete&id=$sql_array->site_id&start=$start&limit=$limit'><font color='red'>Failed to open</font></a><br>");
  61. }
  62.  
  63. flush();
  64.  
  65. }
  66.  
  67.  
  68. print("<br>Link Checking Complete");
  69. mysql_close($link);
  70. ?>
  71. <p><input type="button" onClick="location.href='linkchecker.php?start=<?php echo $start ?>&limit=<?php echo $limit ?>&<?php echo $sess_id ?>'" value="Refresh" name="btnRefresh">&nbsp;
  72. <input type="button" onClick="location.href='linkchecker.php?start=<?php echo $start+30 ?>&limit=<?php echo $limit ?>&<?php echo $sess_id ?>'" value="Next" name="btnNext"></p>
  73. <p>&nbsp;</p>
  74.  
  75. <?include("$CONST_INCLUDE_ROOT/Templates/maintemplate.footer.inc.php");?>
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: MySQL num rows error

  #13  
Jul 24th, 2008
Okay.. You have some errors in your script.
1.
SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y' ORDER BY site_id LIMIT ,
When you execute the script for the 1st time, no LIMIT is set. That is, $start and $limit will be empty. Thats the reason you are getting the error.
2. There has to be a whitespace between site_live='Y' and ORDER in the query
$query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y'ORDER BY site_id LIMIT $start,$limit";

3. Since you aren't assigning or calculating $start and $limit, you always get this error.
My suggestion is to ask the person who did this script for you to give you a working pagination script!
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jul 2008
Posts: 14
Reputation: missaaliyah is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
missaaliyah's Avatar
missaaliyah missaaliyah is offline Offline
Newbie Poster

Re: MySQL num rows error

  #14  
Jul 24th, 2008
Originally Posted by nav33n View Post
Okay.. You have some errors in your script.
1.

When you execute the script for the 1st time, no LIMIT is set. That is, $start and $limit will be empty. Thats the reason you are getting the error.
2. There has to be a whitespace between site_live='Y' and ORDER in the query

3. Since you aren't assigning or calculating $start and $limit, you always get this error.
My suggestion is to ask the person who did this script for you to give you a working pagination script!
The unfortunate thing about asking the person who did it, is that I can no longer have contact, and have since emailed but unfortunately on a long sabatical travelling.

This could sound cheeky, but would you have any advice on how to fix it that it can at least work for now. OKAY, I am cheeky.

Thanks for all your help.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: MySQL num rows error

  #15  
Jul 25th, 2008
You can initialise $start and $limit value. Try the following script. If it works, then, Yay! If it doesn't, then you can post your question in php forum. There are many people who loves to write scripts ! You might get help from any one of them!
  1. <?php
  2. ini_set("max_execution_time", "30000");
  3.  
  4.  
  5. # choose a banner
  6.  
  7. include_once('../includes/db_connect.php');
  8. ?>
  9. <?php
  10. ini_set("max_execution_time", "30000");
  11.  
  12. session_start();
  13.  
  14. # remove members from the mailing list when they click from within the newsletter
  15. check_admin();
  16.  
  17. $start = isset($_REQUEST['start']) ? $_REQUEST['start']:"0";
  18. $limit = 10; // how many records you want to show per page
  19.  
  20. if (isset($HTTP_GET_VARS['mode']) && $HTTP_GET_VARS['mode']=='delete') {
  21. $id=$HTTP_GET_VARS['id'];
  22. $query="DELETE FROM dir_site_list WHERE site_id = $id";
  23. $return=mysql_query($query,$link);
  24. }
  25.  
  26. $query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y'ORDER BY site_id LIMIT $start,$limit";
  27. $return=mysql_query($query);
  28. $TOTAL=mysql_num_rows($return);
  29. $sess_id="PHPSESSID=".session_id();
  30. include("$CONST_INCLUDE_ROOT/Templates/maintemplate.header.inc.php");
  31. ?>
  32.  
  33.  
  34. <?php include('../includes/admin_header.php'); ?>
  35. <?php
  36. while ($sql_array=mysql_fetch_object($return)) {
  37.  
  38. $linkback_url="http://$sql_array->site_linkback";
  39. $linkback_url=trim($linkback_url);
  40.  
  41. print("Checking:$sql_array->site_id> <a href='$linkback_url' target='blank'>$linkback_url</a>");
  42. flush();
  43. $contents="";
  44.  
  45. if (@$fp=fopen($linkback_url,'r')) {
  46. $chktime=time();
  47. while(!feof($fp))
  48. {
  49. $contents.= fread($fp,1024);
  50. if (time() >= $chktime+3) break;
  51. }
  52. fclose($fp);
  53.  
  54. if (strstr($contents,$CONST_LINK_ROOT)) {
  55. $test_result="<font color='green'>Passed</font>";
  56. } else {
  57. $test_result="<font color='red'>Failed</font> -> <a href='linkchecker.php?mode=delete&id=$sql_array->site_id&start=$start&limit=$limit'><font color='red'>[Delete]</font></a>";
  58. }
  59.  
  60. print(" -> $test_result<br>");
  61. } else {
  62. print(" -> <a href='linkchecker.php?mode=delete&id=$sql_array->site_id&start=$start&limit=$limit'><font color='red'>Failed to open</font></a><br>");
  63. }
  64.  
  65. flush();
  66.  
  67. }
  68.  
  69.  
  70. print("<br>Link Checking Complete");
  71. mysql_close($link);
  72. ?>
  73. <p><input type="button" onClick="location.href='linkchecker.php?start=<?php echo $start ?>&limit=<?php echo $limit ?>&<?php echo $sess_id ?>'" value="Refresh" name="btnRefresh">&nbsp;
  74. <input type="button" onClick="location.href='linkchecker.php?start=<?php echo $start+30 ?>&limit=<?php echo $limit ?>&<?php echo $sess_id ?>'" value="Next" name="btnNext"></p>
  75. <p>&nbsp;</p>
  76.  
  77. <?include("$CONST_INCLUDE_ROOT/Templates/maintemplate.footer.inc.php");?>
Last edited by nav33n : Jul 25th, 2008 at 2:54 am.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jul 2008
Posts: 14
Reputation: missaaliyah is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
missaaliyah's Avatar
missaaliyah missaaliyah is offline Offline
Newbie Poster

Re: MySQL num rows error

  #16  
Jul 25th, 2008
Thank you very much for all your help and support, the code works perfectly. I will definitely be giving you more reputation later.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: MySQL num rows error

  #17  
Jul 25th, 2008
Great!
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 5:29 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC