antonio12 Posted November 24, 2008 Share Posted November 24, 2008 Can someone please tell me what I am doing wrong here: I have a piece of MySQL code: // Get values from database for defaults function sajax_update($id, $value) { $id = mysql_escape_string($id); $value = mysql_escape_string($value); mysql_query("UPDATE `speed` SET `speed` = '$value' WHERE `id` = '$id';"); return 'true'; } sajax_export("sajax_update"); sajax_handle_client_request(); // Get values from database for defaults $result = mysql_query("SELECT * FROM speed"); $defaults = array(); while($rw = mysql_fetch_array($result)) { $defaults[$rw['id']] = $rw['speed']; } I get the following error for the code above: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in index.php on line 33 I have noted line 33 in red above. Can someone please help me understand what this means and how I can resolve it? Thank you for your help. Antonio Quote Link to comment https://forums.phpfreaks.com/topic/134065-solved-mysql-code-help/ Share on other sites More sharing options...
revraz Posted November 24, 2008 Share Posted November 24, 2008 Your query is failing. Use mysql_error() after your query to see why. Do you have a connection to the database? Quote Link to comment https://forums.phpfreaks.com/topic/134065-solved-mysql-code-help/#findComment-697897 Share on other sites More sharing options...
antonio12 Posted November 24, 2008 Author Share Posted November 24, 2008 Thanks for your help revraz!! my "database name" variable was not assigned! DUH!!! Antonio! Quote Link to comment https://forums.phpfreaks.com/topic/134065-solved-mysql-code-help/#findComment-697960 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.