|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
supplied argument is not a valid MySQL result resource
Greetings,
I have a problem which shows up *intermittently* when executing a simple query. Basically, mysql_query() returns no resource *some* of the time: "PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/..." When I trap the error using mysql_error(), I get the following: "No Database Selected" For kicks, I altered the query to use the fully qualified table name (<db>.<table>), and the error changed to: "Access denied for user: 'username@%' to database 'db'" I was able to replicate this on a browser as well as using "ab" with no concurrency. The system will sometimes handle 1000 or more queries without any problems, and then a bunch of errors will appear. I cannot roll this out into a production environment until this is fixed. I would really appreciate any advice. Here's the relevant code: $conn = mysql_connect(CHAR_DB,CHAR_DB_USER,CHAR_DB_PASS) or die("Cannot connect to db."); mysql_select_db(USER_DB, $conn); $sql = "SELECT cash FROM cash WHERE id = '$id'"; $res = mysql_query($sql); if (!$res) { error_log('Invalid query: ' . mysql_error()); } $numrows = mysql_num_rows($res); Thanks! |
|
#2
|
||||
|
||||
|
A simple debugging technique...
Add this to your code: $res = mysql_query($sql) or die("Error ".mysql_errno().": ".mysql_error()."<br>\nThe SQL sent was: $sql"); Refer to the PHP documentation if you are unsure of what these functions do: |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > supplied argument is not a valid MySQL result resource |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|