Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

Hey all -
Been away from the programming world for a while (thank you Marine Corps), and am running into an error that has me stumped. Here's the error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/lfg57/public_html/index.php on line 16
No database selected

and here's the code (line 16 in BOLD):
<?php
##ini_set('display_errors', 1); error_reporting(E_ALL);
if (!isset($_SESSION)) { session_start(); }

if(isset($_GET['aid'])&& $_GET['aid']!=''){
$_SESSION['aid'] = $_GET['aid'];
}

require_once('./Connections/lfg.php');
mysql_select_db($database_lfg, $lfg);

checkCookie();

$g_getFree = "select * from Free_Weekends";
$r_getFree = mysql_query($g_getFree);
$free = mysql_fetch_assoc($r_getFree);
if (!is_null($free['Free']) && strtolower($free['Free'])!='no' && $free['Free']!=''){
$_SESSION['free'] ='yes';
}else{
$_SESSION['free'] ='no';
}

//echo $_SESSION['free']."<BR>";
?>

Thank you in advance!

Comments

  • Probably because something's wrong with the query, to see if there's an error doing the query you can check if the value returned by "mysql_query" is not null:
    if (!$r_getFree) {
        die('Error: '. mysql_error());
    }
    
  • The table probably doesn't exist. The table name is case sensitive, so check your table name. Also check whether you're accessing the right database. It might be that the table doesn't exist because you're looking for it in the wrong place.

    I assume you were able to connect to MySQL and a database, otherwise you would've had some other errors too. I assume you would've told us if there were any other errors.

    Just some speculation. I might be wrong.
Sign In or Register to comment.