Results 1 to 8 of 8

Thread: mySQL help please

  1. #1
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy mySQL help please

    ive been busy alot trying to fix the problem but i cant resolve it:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 35
    and
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 42 can someone please help me thx alot

    <?php
    header("Cache-control: no-cache, must-revalidate\r\n");
    require_once("config.php");
    if(isset($_GET['char']))
    {
    $con = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS);
    mysql_select_db(MYSQL_DATA);
    $Name = mysql_real_escape_string($_GET['char']);
    $Realm = mysql_real_escape_string($_GET['realm']);
    $Realm = (int)$Realm+1;
    $res = mysql_query("SELECT sqlhost,sqluser,sqlpass,chardb FROM realms WHERE entry='{$Realm}'");
    $row = mysql_fetch_array($res);
    mysql_close($con);
    $con = mysql_connect($row['sqlhost'],$row['sqluser'],$row['sqlpass']);
    mysql_select_db($row['chardb']);
    $res = mysql_query("SELECT guid FROM characters WHERE name='{$Name}'");
    if(mysql_num_rows($res) == 1)
    {
    $row = mysql_fetch_array($res);
    echo $row['guid'];
    }
    else
    {
    echo "0";
    die;
    }
    mysql_close($con);
    }
    else
    {
    $con = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS);
    mysql_select_db(MYSQL_DATA);
    $res = mysql_query("SELECT entry,name FROM realms");
    $REALMS = "{";
    while($row = mysql_fetch_array($res))
    {
    $REALMS .= ((int)$row['entry']-1).":\"".$row['name']."\",";
    }
    $REALMS .= "\"undefined\":0}";
    $res = mysql_query("SELECT entry,name,realm,description,price FROM rewards");
    $REWARDS = "{";
    while($row = mysql_fetch_array($res))
    {
    $REWARDS .= ((int)$row['entry']-1).":{name:\"".$row['name']."\",realm:".((int)$row['realm']-1).",description:\"".addslashes($row['description'])."\",price:".$row['price']."},";
    $DESCRIPTIONS .= "<div class=\"SlidingPanelsContent\" style=\"padding:2px;\">".$row['description']."</div>";
    }
    $REWARDS .= "\"undefined\":0}";
    $REWARDS = str_replace("\r","\\r",$REWARDS);
    $REWARDS = str_replace("\n","\\n",$REWARDS);
    include("form.php");
    mysql_close($con);
    }
    ?>

  2. #2
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Default

    Is your conditional statement correct?

    if
    {}
    else{}
    }
    else{}

  3. #3
    Join Date
    Jul 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    lol I've never seen two elses at the same time, rather try use elseif()

  4. #4
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    tfit, no, it is correct. Look at code. It starts with if, then there go another if, then else, then first if closed, then else.

  5. #5
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Default

    Quote Originally Posted by allahverdi View Post
    tfit, no, it is correct. Look at code. It starts with if, then there go another if, then else, then first if closed, then else.
    I totally missed that first if.
    He man where were you when I needed you :-). Your nickname is probably Mr. timesaver

  6. #6
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    Change all:
    Code:
    mysql_select_db(MYSQL_DATA);
    to:
    Code:
    mysql_select_db(MYSQL_DATA) or die(mysql_error());
    I think you have error with connection.

  7. #7
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    tfit, i'm not mr. timesaver. I'm just intent man

    Nah, Just call me Mr.TimeSaver

  8. #8
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Default

    Quote Originally Posted by allahverdi View Post
    tfit, i'm not mr. timesaver. I'm just intent man

    Nah, Just call me Mr.TimeSaver
    Mr.TimeSaver it will be

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •