I try to run a mysql query in my website using php but I get the error mentioned below:-
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
I try to run a mysql query in my website using php but I get the error mentioned below:-
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
That usually means that there was an error with your query. However, no one can help you unless you post the code with this error.
There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.
The error message means what it says, which means that your problem lies in the query or the connection -- or you could simply have a typo in your code. You'd need to post code in order to get any more help.
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)
plz use mysql error () command.
Eg:
<?php
$query="select * from tble";
mysql_query($query) or die(mysql_error());
?>
it will help you to find out errors.
Last edited by varunaroli; 06-06-2010 at 03:20 AM.
Just make sure you don't use or die or output mysql_error() for non-admin users in production code.
Last edited by misson; 06-08-2010 at 12:31 PM.
Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.Misson, not Mission.
try this out http://w3schools.com/php/php_mysql_intro.asp . It has good tutorials
Last edited by jedaivokters; 06-09-2010 at 07:18 AM.
W3Schools is outdated, inaccurate and incomplete, and that's not just my opinion.
Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.Misson, not Mission.
hi im connecting my db on x10hosting which uses cpanel however i can't seem to connect it, i dont know what to put on username and localhost and the dbname..please help!