Show data

Discussion in 'PHP' started by Arsench, Sep 5, 2007.

  1. #1
    hi im traing to show data from mysql db but cant do this i think that the php code is correct please any advice?
    every time receiving Unable to select database $dbName error


    this is the code the config names is correct

    <?php
    $hostName = "localhost";
    $userName = "///////";
    $password = "///////";
    $dbName = "///////";

    mysql_select_db($dbName) or die("Unable to select database $dbName");

    $sql = 'SELECT * FROM `ars` ';


    $result=mysql_query($sql);


    echo "<table border ='0'>";
    echo "<tr><td>ID</td><td>Category</td><td>E-mail</td><td>URL</td><td>Description</td></tr>";

    while ($tablerows = mysql_fetch_row($result))
    {

    echo "<tr><td>".$tablerows[0]."</td><td>".$tablerows['1']."</td><td>".$tablerows[2]."</td><td>".$tablerows[3]."</td><td>".$tablerows[4]."</td></tr> ";
    }
    echo "</table>";

    mysql_close($db);
    ?>
     
    Arsench, Sep 5, 2007 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First you have to connect.

    mysql_connect($hostName, $userName, $password);
    PHP:
     
    MMJ, Sep 5, 2007 IP