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 392,068 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 4,246 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:
Views: 469 | Replies: 16
Reply
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

MySQL num rows error

  #1  
29 Days Ago
I have very limited use of using MySql - but I am trying to fix this code and it seems to be corrent. But I am still getting the error.
The website is a web directory, and the code itself checks to see the websites that arent linking back to the site.

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/imedia/public_html/uk-webdirectory.info/admin/linkchecker.php on line 34
This is Line 34
  1. $total=mysql_num_rows($return);

This is Lines 32 - 35
  1. $query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y'ORDER BY site_id LIMIT $start,$limit";
  2. $return=mysql_query($query,$link);
  3. $total=mysql_num_rows($return);
  4. $sess_id="PHPSESSID=".session_id();

I have searched the net and tried various other methods that were posted on this forum and others and still I get the same error.

Any help and expertise would be much appreciated.
AddThis Social Bookmark Button
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: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: MySQL num rows error

  #2  
28 Days Ago
The error is because there is something wrong in your query. Print the query, execute it in mysql console or phpmyadmin. (Also post it here)
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
Location: Hyderabad,India.
Posts: 522
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Re: MySQL num rows error

  #3  
28 Days Ago
change this :
$return=mysql_query($query,$link);

to:
$return=mysql_query($query);
Champions Are Not SuperNatural,They Just Fought For One More Second When Every One Else Quit...Some times That One Second Of Effort Gives You The VICTORY...
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: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: MySQL num rows error

  #4  
28 Days Ago
Originally Posted by Shanti Chepuru View Post
change this :
$return=mysql_query($query,$link);

to:
$return=mysql_query($query);


That definitely wouldn't matter. Thats because mysql_query can take an optional parameter of link identifier (the variable used to 'open' the connection).
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
Location: Hyderabad,India.
Posts: 522
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Re: MySQL num rows error

  #5  
28 Days Ago
k...nav...
thanks for indiacating........
Champions Are Not SuperNatural,They Just Fought For One More Second When Every One Else Quit...Some times That One Second Of Effort Gives You The VICTORY...
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

  #6  
28 Days Ago
Originally Posted by nav33n View Post
The error is because there is something wrong in your query. Print the query, execute it in mysql console or phpmyadmin. (Also post it here)


I am not sure what you mean by printing the query, but I did test the first line and then the group of lines and the results were.

Tested:
$total=mysql_num_rows($return);

 MySQL said: 
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$TOTAL=mysql_num_rows($return)' at line 1 

Tested:
$query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y'ORDER BY site_id LIMIT $start,$limit";
$return=mysql_query($query,$link);
$total=mysql_num_rows($return);
$sess_id="PHPSESSID=".session_id();

 MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y'ORDE' at line 1 

Where can I find the manual and version of MySQL I have and any ideas on how to fix it. I really appreciate anything you can tell me, as I am a newbie at this. Usually I just install scripts, not edit them.
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: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: MySQL num rows error

  #7  
28 Days Ago
  1. $query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y' ORDER BY site_id LIMIT $start,$limit";
  2. echo $query;
Tell us what it prints.
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

  #8  
28 Days Ago
It's reply is practically the same as before I think.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$query="SELECT * FROM dir_site_list WHERE site_sponsor='N' AND site_live='Y' ORD' at line 1
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: 238
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: MySQL num rows error

  #9  
28 Days Ago
Can you post your updated code ? echo $query; should print out the query. But anyway, post your complete code.
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

  #10  
28 Days Ago
What do you mean by updated code? Also I am confused about print out the query, do you mean its response to the query I run in phpmyadmin?

Did you want me to post the whole page?
Last edited by missaaliyah : 28 Days Ago at 7:02 am.
Reply With Quote  
Reply

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

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

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

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