Hello

New here, so don't know if doing this right, I am getting an error message that goes like this:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/target/geo/index.php on line 48
(here is the line in question)
$count_result = mysql_num_rows($result);


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/target/geo/index.php on line 53
(here is the line in question)
$thirty_count_result = mysql_num_rows($thirty_result);

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/target/geo/index.php on line 74

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/target/geo/index.php on line 74

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/target/geo/index.php on line 74
(here is the line in question)
$country_count_r = mysql_fetch_array($country_count_result);


any idea's, or do you need more info?

silverfox

Recommended Answers

All 2 Replies

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:

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.

hi Troy,

This is my situation: the script normally worked, but after about 10 days, I saw Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/function.inc.php on line 28

The page don't show half page, all database is empty, I think (because I don't see any records).

I tried to write your method, but after that I saw only two lines in my page. What is wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.