View Full Version : help with mysql_fetch_array($result)
subbu
02-17-2006, 11:56 PM
Hi,
I have a database functions file which was included at the top of my php file. The php file when run, calls a function which has mysql_fetch_array($result) but I am getting the following error.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
can any body help me?
Thanks
subbu
Hi,
I have a database functions file which was included at the top of my php file. The php file when run, calls a function which has mysql_fetch_array($result) but I am getting the following error.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
can any body help me?
Thanks
subbu
I found this article from here (http://www.daniweb.com/techtalkforums/thread10544.html).
ATTENTION ALL NEWBIES!
"supplied argument is not a valid MySQL resource" is almost always the result of an invalid SQL statement being passed to the database. When you are using a scripting language to dynamically build a SQL statement, it is VERY easy to introduce problems into your SQL string.
The good news is that this problem is very easy to troubleshoot. Find the line in your code where you execute the SQL statement. (mysql_query() for example). Just above that line add code similar to this:
PHP Code:
echo "<hr />".$sql."<hr />";
exit();
Replace $sql with your variable name. This will display the SQL statement in the browser. Now examine that SQL statement. Do you see any problems? Yes? Fix them. No? Then Copy & Paste that statement into a Query window in phpMyAdmin or in whatever admin tool you use. Run the statement and see what errors you get. Usually, the database will do a pretty good job of telling you what is wrong with your statement.
Once you discover the problem, modify your PHP (or other script) to remedy the issue.
good luck...
. .
subbu
02-18-2006, 01:31 AM
Thank you for your reply,
But the query is fine. It is not the problem with the query because it is working very fine in my local host. But when I upload the code into the site I am getting that error. I think it is the problem with the latest version of php. Can you please tell me how to solve it
thanks
subbu
HellBelly
02-20-2006, 06:21 PM
I've been getting this same error all day long since about 10:00.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sweptlin/public_html/includes/sql_layer.php on line 238
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sweptlin/public_html/includes/sql_layer.php on line 342
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sweptlin/public_html/includes/sql_layer.php on line 238
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sweptlin/public_html/includes/sql_layer.php on line 238
It's affecting my Users online block on PHPNuke site. The last time it did this it was something on bluehosts end and eventually corrected itself.
So far I still have the problem.
My site:
http://www.sweptline.org
Can someone at bluehost check this out?
HellBelly
02-20-2006, 06:45 PM
i'm now getting DB connection errors etc...
HellBelly
02-20-2006, 07:27 PM
Example:
SQL Error : 2013 Lost connection to MySQL server during query
SELECT t.forum_id, t.topic_id, p.post_time FROM nuke_bbtopics t, nuke_bbposts p WHERE p.post_id = t.topic_last_post_id AND p.post_time > 1140485511 AND t.topic_moved_id = 0
Line : 241
File : /home/sweptlin/public_html/modules/Forums/index.php
page1ink.
06-02-2006, 04:15 PM
a lot of MySQL errors are just typos. make sure your field names are surrounded in backticks (``, the tilde key) and your values are surrounded by apostrophes ('', single quotes). make sure your field names are correct and make sure your variables are either concated correctly or surrounded in curly braces {}.
hope that helps!
areidmtm
06-02-2006, 05:19 PM
post your code
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.