Problems with script and mysql

Discussion in 'MySQL' started by Devana, May 10, 2008.

  1. #1
    I am getting a few errors on one of my scripts. Hope someone can help me.

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a1343289/public_html/styles.php on line 15

    $config=mysql_fetch_array(mysql_query("select * from sbprj_config"));
    PHP:

    And this error:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a1343289/public_html/admin/index.php on line 5

    $config=mysql_fetch_array(mysql_query("select * from sbprj_config"));
    PHP:

    Well...It's the same error. Hope someone has some suggestions :)
     
    Devana, May 10, 2008 IP
  2. Nalltaroh

    Nalltaroh Peon

    Messages:
    54
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    MySQL queries aren't case sensitive?
     
    Nalltaroh, May 10, 2008 IP
  3. Devana

    Devana Well-Known Member

    Messages:
    987
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    130
    #3
    No, doesn't seem like it. I've tried to edit it, but the same error shows up.
     
    Devana, May 10, 2008 IP
  4. Nalltaroh

    Nalltaroh Peon

    Messages:
    54
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    $config=mysql_fetch_array(mysql_query("SELECT * FROM sbprj_config"));
    PHP:
    Should work :| If doesn't, please PM me with your whole .php page.
     
    Nalltaroh, May 10, 2008 IP
  5. allaboutgeo

    allaboutgeo Peon

    Messages:
    85
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Split your code into 2 queries and use mysql_error() to know the exact syntax error
    $result = mysql_query("select * from sbprj_config") or die(mysql_error());
    $config=mysql_fetch_array($result);
    Code (php):
     
    allaboutgeo, May 10, 2008 IP
  6. chtdatweb

    chtdatweb Well-Known Member

    Messages:
    1,473
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    160
    #6
    Try this:

    $query = "SELECT * FROM sbprj_config";
    $result = mysql_query($query) or die(mysql_error());
    $config = mysql_fetch_array($result) or die(mysql_error());

    See if that helps ;)
     
    chtdatweb, May 10, 2008 IP
  7. Devana

    Devana Well-Known Member

    Messages:
    987
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    130
    #7
    Thanks for all the suggestions guys, but instead of the error, I now only get: Table '*username*_get.sbprj_config' doesn't exist

    And I think I see the problem now...I can't find the file sbprj_cofig. Without this, of course, I will get an error...?
     
    Devana, May 10, 2008 IP
  8. chtdatweb

    chtdatweb Well-Known Member

    Messages:
    1,473
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    160
    #8
    It is not a file it is a table within your SQL database :)
     
    chtdatweb, May 10, 2008 IP
  9. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #9
    yup... you are specifying records to be selected from a table that does not exist. ;)
     
    daboss, May 10, 2008 IP
  10. allaboutgeo

    allaboutgeo Peon

    Messages:
    85
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    If this is not an error then how an error looks alike?
     
    allaboutgeo, May 10, 2008 IP