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 373,494 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 3,875 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: 48562 | Replies: 5
Reply
Join Date: Jun 2005
Posts: 1
Reputation: sri_sep29 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sri_sep29 sri_sep29 is offline Offline
Newbie Poster

Help Supplied argument is not a valid MySQL result resource

  #1  
Jun 23rd, 2005
hi,

i write a code like this

$user_id = $hd_cookie['user_id'];
$user_password = $hd_cookie['auth'];


$sql = "SELECT * FROM hd_users WHERE user_id='$user_id' AND user_password='$user_password'";

$r_user = mysql_query($sql);
$num=mysql_num_rows($r_user); //line 24

it shows Warning
Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htdocs\helpdeskfinal\includes\auth.php on line 24

when i print the sql statement and run the statement in MySql Window it gives the result.but from here it didn't give the result why?

i am using PHPTRIAD 2.1.1 version is this version supports mysql_num_rows????

please solve my problem

Thanks
Srinivas
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2004
Posts: 715
Reputation: Phaelax is on a distinguished road 
Rep Power: 6
Solved Threads: 27
Phaelax Phaelax is offline Offline
Master Poster

Re: Supplied argument is not a valid MySQL result resource

  #2  
Jun 23rd, 2005
It might return an error if the result of the SELECT contained no rows, but I could be wrong. The code looks ok, I'm not sure what the problem could be.
Reply With Quote  
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Supplied argument is not a valid MySQL result resource

  #3  
Jun 23rd, 2005
Debugging tip: You mention that you run the statement in MySql window, and it works, but did you actually copy & paste the statement as generated by your code? Right after you build the $sql variable, output it like so:
[php]
echo $sql;
exit();
[/php]
Then copy & paste that output in your MySql query windows and see if it works. You may find your problem.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
Join Date: Aug 2005
Posts: 1
Reputation: Jero is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jero Jero is offline Offline
Newbie Poster

Re: Supplied argument is not a valid MySQL result resource

  #4  
Aug 26th, 2005
I had exactly the same problem and I knew for certain I did spell the cellnames and tablename right.

I've found the solution. Simply put all the cellnames and tablename between ``. That's all!

[php]
$sql = "SELECT * FROM `hd_users` WHERE `user_id`='$user_id' AND `user_password`='$user_password'";
[/php]

If this doesn't work, first get the user_id and user_password out of the ``, only hd_users. If that doesn't work either, I don't it, for me it worked

grtz, Jero
Reply With Quote  
Join Date: Feb 2007
Posts: 2
Reputation: manofgames is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
manofgames manofgames is offline Offline
Newbie Poster

Re: Supplied argument is not a valid MySQL result resource

  #5  
Feb 28th, 2007
Thanks very much, I've just find this via google, and its got me out of a tight spot

Thanks again, and sorry to bring up an old topic
Reply With Quote  
Join Date: Aug 2007
Posts: 1
Reputation: gregarious is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gregarious gregarious is offline Offline
Newbie Poster

Question Re: Supplied argument is not a valid MySQL result resource

  #6  
Aug 18th, 2007
Thanks, this thread helped me figure out a problem I was having too.

In my case, the problem was a missing semicolon at the end of the SQL statement. Was this also the problem for the original poster, I wonder?

In other words, this:

...snip... AND user_password='$user_password'";

should have been this:

...snip... AND user_password='$user_password';";
Last edited by gregarious : Aug 18th, 2007 at 4:20 am. Reason: clarify with code example
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 5:57 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC