![]() |
| ||
| Supplied argument is not a valid MySQL result resource 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 |
| ||
| Re: Supplied argument is not a valid MySQL result resource 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. |
| ||
| Re: Supplied argument is not a valid MySQL result resource 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. |
| ||
| Re: Supplied argument is not a valid MySQL result resource 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 |
| ||
| Re: Supplied argument is not a valid MySQL result resource 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 :( |
| ||
| Re: Supplied argument is not a valid MySQL result resource 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';"; |
| All times are GMT -4. The time now is 10:26 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC