I have the following warning that comes up when I try to load the site and have no idea why this is happening. Can someone help? Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/mysite.com/config.php on line 22 Here is the config.php file: <?php // mySQL information $server = 'localhost'; // MySql server $username = ''; // MySql Username $password = '' ; // MySql Password $database = ''; // MySql Database // The following should not be edited $con = mysql_connect("$server","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$database", $con); //mysql_query("UPDATE ava_games SET height='300' WHERE height='0'") or die (mysql_error()); // $sql = mysql_query("SELECT * FROM ava_settings"); $row = mysql_fetch_array($sql); $site_name = $row['site_name']; $site_description = $row['site_description']; $site_keywords = $row['site_keywords']; $site_url = $row['site_url']; $seo_on = $row['seo_on']; $template_url = $row['template_url']; $max_results = $row['max_results']; $image_height = $row['image_height']; $image_width = $row['image_width']; $adsense = $row['adsense']; $cat_numbers = $row['cat_numbers']; $email_on = $row['email_on']; $add_to_site = $row['add_to_site']; $plays = $row['plays']; $language = $row['language']; $featured = $row['featured_games']; $play_limit = $row['play_limit']; $adsense_id = $row['adsense_id']; $new_plays = 4; // I have left out my password, etc for obvious reasons Line 22 - $row = mysql_fetch_array($sql); Any help that can be offered is greatly appreciated. Thanks, Gerald
I looked around and found some people with a similar problem. This thread should help you. http://forums.devarticles.com/mysql...plied-argument-is-not-a-valid-mysql-3251.html
Thanks QuackWare. I checked it out, but didn't find an answer to this particular problem. Anybody else with any ideas?
Thanks crivion. I added the "@" but nothing happens, just the line doesn't show up anymore. The site still doesn't load
Did you read this quote from the page I gave? It seemed to solve the problem for those who were posting. Basically add the "or die" part to give a more descriptive error message and the problem is most likely related to your syntax. Here is the quote.
Thanks to those who are trying to help, but I am really very new at using PHP and have no experience with mysql. Does anyone have a solution to my problem? The page won't load, but instead I get this message Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/mysite.com/config.php on line 22 Line 22 is: $row = mysql_fetch_array($sql); Thanks
Then the problem is that this line isn't working mysql_select_db("$database", $con); PHP: check what $database contains if anything Also, you con't need the " " around it
That error is usually because it failed connecting to the db somewhere along the line, make the sure db exists and that you entered the db info correctly. Also you don't need the double quotes around the variables. Use this code, and reply with the errors (if any to debug). Replace this: // The following should not be edited $con = mysql_connect("$server","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$database", $con); PHP: With this: $con = mysql_connect($server,$username,$password) or die(mysql_error()); mysql_select_db($database, $con); or die(mysql_error()); PHP: