1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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

Discussion in 'PHP' started by Downtime, Nov 12, 2011.

  1. #1
    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!
     
    Downtime, Nov 12, 2011 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    Where is $database_lfg defined ? should be set to the name of your database before line 10.
     
    shallowink, Nov 12, 2011 IP
  3. Downtime

    Downtime Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    okay fixed the error by adding an "@" sign in line 16, but now it says no dbase selected. its weird this was working fine with no changes and then one morning this pops up.
     
    Downtime, Nov 12, 2011 IP
  4. avinash gaud

    avinash gaud Member

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    26
    #4
    Hello,

    May be the variable $database_lfg is not getting value you can echo it and check or you can hard code the database name and check if it works..
     
    avinash gaud, Nov 12, 2011 IP