Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Could someone please tell me what I did wrong?

    Here is a script I have started working on.
    My web host uses PHP 4.2.2 and MySql 3.23.51

    <?

    // Database Variables

    $server = "localhost";
    $database = "tsdbase";
    $username = "frank";
    $password = "chicken";
    $table = "names";

    // Connect to Database

    $db = mysql_connect($server,$username,$password,$database);

    $res = mysql_query("SELECT * FROM $table", $db);

    $data = mysql_fetch_array($res);

    ?>

    When I run the script, I get the following error :

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

    What am I doing wrong?
    All I want to do is to open a database and display a table to the browser.

    Todd
    Last edited by tvollmer; 08-22-2002 at 10:52 PM.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    <?

    // Database Variables

    $server = "localhost";
    $database = "tsdbase";
    $username = "frank";
    $password = "chicken";
    $table = "names";

    // Connect to Database

    $dbcnx = @mysql_connect($server,$username,$password) or die ("Database Connection Error");

    $dbhandle = mysql_select_db($database, $dbcnx);

    $res = mysql_query("SELECT * FROM '$table'", $dbhandle);

    $data = mysql_fetch_array($res);

    ?>
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Thanks

    That made it work!

    Thank you!

    Todd

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    You're welcome.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

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