Linking PHP with mySQL problem [duplicate]
Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home2/wizardso/public_html/tab1_content.php on line 6
thi开发者_StackOverflow社区s is the error that i am getting when i uploaded my db-driven webpage to my web-hosting. The same webpage was running smoothly on my localhost/ server. But its not working over the internet. Please HELP.
UPDATE
These are the contents of my file tab1_content.php
<?php
$query="select * from subcatagory where catagory_id='c001'";
$res=mysql_query($query,$con);
$query_cat="select * from catagory where catagory_id='c001'";
$res_cat=mysql_query($query_cat,$con);
$current_cat=mysql_fetch_assoc($res_cat);
?>
That error most likely results from the fact that there is something wrong with the mysql_query ("result resource") that you are calling mysql_fetch_assoc() on. Try running just the query and see what errors are returned.
All the error you posted tells you is that something went wrong with the query, it could be anything from a MySQL database connection problem to a typo in your script. Please show us your code so we can see what exactly is causing the error.
echo mysql_error();
Edit
Your code appears to look OK- are you sure that there is table within your database called "catagory" (then again- are you sure it's not "category"?), and that within that database is a record with a catagory_id
of "c001"?
To test this, try echoing mysql_affected_rows();
, this gives the number of rows "affected" by the last query. If you get 0
, then that means that there is no such record.
Whatever result set you're passing to mysql_fetch_assoc()
is invalid because the query with mysql_query()
did not complete. Check the mysql error with mysql_error()
Check your Database connectivity settings i hope that it may be one of the reason for the empty result set.
Thanks
精彩评论