Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    Ok, I have gone over this a million times... and being new to php, even If i saw the problem, I wouldnt' know it. But here is what's going on. I have a php script:

    ************************************************** *********************************
    <?php
    $sql = "select * from search order by romid desc limit 5";
    $query = mysql_query($sql);
    while ($row = mysql_fetch_array($query)) {
    $romid = $row["romid"];
    $name = $row["name"];
    $namenum = strlen($name);
    if ($namenum > 40) {
    $name = substr($name, 0, 40);
    }
    echo "<div align=\"center\"><a href=\"rompage.php?idrom=$romid\">";
    echo "<img width=\"240\" height=\"160\" src=\"".$row["titlepicture"]."\" border=\"1\"></img></a></div>";
    echo "<a href=\"rompage.php?idrom=$romid\"><b>&nbsp$name</b>...</a>";
    echo "<br>";
    echo "<div align=\"center\"><img width=\"242\" height=\"7\" src=\"images/ev_39.gif\" border=\"0\"></img></div>";
    }
    mysql_close();
    ?>
    ************************************************** *********************************

    Now, I have that EXACT script in my .php file twice... the first one works, and then, for some reason. the second script (IDENTICAL) does not work... and instead gives the error:

    "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site127/fst/var/www/html/NewDesignVBeta/roms.php on line 191"

    Anyone have any idea's?? The page can be found here: http://ev.net/NewDesignVBeta/roms.php
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  2.  

  3. #2
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    That means that your query was successful. Try changing it to the following, it will let you know if there was an error with query:

    $query = mysql_query($sql) or die(mysql_error());
    There and Back Again :Ogre:

  4. #3
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    Ok, visit the page again... now it says: "No Database Selected" when I know that at the top it selected the database.. that is how the middle column is displaying the games.. but why not the column on the right as well?!
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  5. #4
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    That means that you didn't connect to the database properly.

    You have to use mysql_connect and mysql_select_db on every page before you can perform any queries. and don't call mysql_close untill the very very end of your script.
    There and Back Again :Ogre:

  6. #5
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    Ohhhh, thanks I think I just found out the problem.... what you said half-helped.... I already know I connected to database etc correctly... but since they are exactly the same script... after the first script, it does mysql_close making the second (identical) script not work.
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:26 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com