MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 11th, 2004, 07:45 AM
axiomatic axiomatic is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 axiomatic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mysql_numrows():

hi all,

i am a bit new to mySQL so this may well be a simple thing to fix, but i can't see it.

i have a piece of code for accessing a database, which contains these lines:


PHP Code:
 08:   $query=" SELECT * FROM contacts WHERE id='$id'";
09:   $result=mysql_query($query);
10:   $num=mysql_numrows($result);
11:   mysql_close(); 



however, when i try and run the code, i get this error:


Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home2/freakish/public_html/mysql/update.php on line 10



any suggestions as to why it is doing this would be appreciated as i don't have a clue as to why...? i've searched google with no help, it just keeps finding other peoples errors, lol.

thanks in advance,

Reply With Quote
  #2  
Old January 11th, 2004, 07:24 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I posted this in a different thread, but try this as a debugging technique:

$result = @mysql_query($query) or die("Error ".mysql_errno().": ".mysql_error()."\nQuery: $query");

Generally when an argument, that's supposed to be results, isn't supplied, its because teh query wasn't executed properly...

If the query fails, it' will explain why, and display the query...

Reply With Quote
  #3  
Old January 11th, 2004, 08:11 PM
axiomatic axiomatic is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 axiomatic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for the reply.

i had just tried this as i noticed someone had replied, and it informed me that it couldn't connect to the database - turns out the database connect line was missing.. oh dear, i truly am inexperienced

but it works now, at least!

Reply With Quote
  #4  
Old August 1st, 2007, 01:19 AM
johnrobinm johnrobinm is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 1 johnrobinm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 59 sec
Reputation Power: 0
Nice code

Thanks for this tip!

jr


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > mysql_numrows():


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT