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

Discussion in 'MySQL' started by belgin fish, Aug 20, 2009.

  1. #1
    hey, I'm having a problem.

    I'm getting the following error :

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /loadsettings.inc.php on line 4
    Code (markup):
    Here is loadsettings.inc.php

    <?php
    
    $result = mysql_query("SELECT * FROM `settings`");
    $r = mysql_fetch_array($result);
    
    
    $password = $r['password'];
    $website = $r['website'];
    $webtitle = $r['title'];
    $description = $r['description'];
    $keywords = $r['keywords'];
    $maxsizeguest = $r['maxsizeguest'];
    $maxsizemember = $r['maxsizemember'];
    $watermark = $r['watermark'];
    
    
    ?>
    
    
    
    Code (markup):
    Anyone know whats wrong?

    Thanks
     
    belgin fish, Aug 20, 2009 IP
  2. Dreads

    Dreads Well-Known Member

    Messages:
    1,884
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    150
    #2
    You need to connect to the database -_-
    If there is a config file
    do something like
    
    include('config.php');
    
    Code (markup):
    at the start
     
    Dreads, Aug 20, 2009 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    Means that no rows were returned.

    Try this to debug...

    
    if(!$result = mysql_query("SELECT * FROM `settings`"))
    {
    die(mysql_error());
    }
    
    $r = mysql_fetch_array($result);
    
    PHP:
     
    jestep, Aug 20, 2009 IP
  4. belgin fish

    belgin fish Well-Known Member

    Messages:
    1,544
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    185
    Digital Goods:
    2
    #4
    lmao, ok now i feel dumb. Thanks h0ly and jestep. It was just not connecting to the db, thats all. Dreads solution worked
     
    belgin fish, Aug 20, 2009 IP