www.webdeveloper.com
Results 1 to 7 of 7

Thread: What's wrong with this code......

  1. #1
    Join Date
    Mar 2007
    Posts
    27

    Unhappy What's wrong with this code......

    Hi there,

    I'm going over PHP and MYSQL for dummies, and I'm relative new to this server language, anyway, please see below the code, it's not displaying the results, I would really appreciate any help regarding this matter.......

    <?php
    /*Program: Victory Health display.php
    */
    ?>
    <html>
    <head><title>Victory</title></head>
    <body>
    <?php
    $user="";
    $host="";
    $password="";
    $database="test";
    $connection = mysql_connect($host,$user,$password)
    or die ("couldn't connect to server");
    $db = mysql_selectdb($database,$connection)
    or die ("Couldn't connect to server");
    $query = "SELECT * FROM tblWebData LIMIT 0, 30";
    $result = mysql_query($query)
    or die("Couldn't execute query.");
    /*Display results in a table */
    echo "<table cellspacing='11'>";
    echo "<tr><td colspan='1'><hr></td></tr>";
    while ($row = mysql_fetch_array($result))
    {
    extract($row);
    echo "<tr>\n
    <td>$AgencyName</td>\n
    <td>$DescriptionofAgency</td>\n
    <td align='right'></td>\n
    </tr>\n";
    echo "<tr><td colspan='1'><hr></td></tr>\n";

    }
    echo "</table>\n";
    ?>
    </body></html>
    Thanks and God Bless.....

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,252
    Do you get any error messages at all? If not, you might try adding the following lines at the start of your script, so that all run-time errors, warnings and notices are displayed:
    PHP Code:
    <?php
    ini_set
    ('display_errors'1);
    error_reporting(E_ALL);
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2007
    Posts
    151
    PHP Code:
    <?php
    /*Program: Victory Health display.php
    */
    ?>
    <html>
    <head><title>Victory</title></head>
    <body>
    <?php
    $user
    ="";
    $host="";
    $password="";
    $database="test";
    $connection mysql_connect($host,$user,$password) or die ("couldn't connect to server");
    $db mysql_selectdb($database,$connection) or die ("Couldn't connect to server");
    $query "SELECT * FROM tblWebData LIMIT 0, 30";
    $result mysql_query($query) or die("Couldn't execute query.");
    /*Display results in a table */
    echo "<table cellspacing='11'>";
    echo 
    "<tr><td><hr></td></tr>";
    while (
    $row mysql_fetch_array($result))
    {

    echo 
    "<tr><br /><td>{$row['AgencyName']}</td><br />";
    echo 
    "<td>{$row['DescriptionofAgency']}</td><br />";
    echo 
    "<td align='right'></td><br /></tr><br />";
    echo 
    "<tr><td ><hr></td></tr><br />";

    }
    echo 
    "</table><br />";
    ?>
    </body></html>
    "In retrospect it becomes clear that hindsight is definitely overrated!" ~ Alfred E. Neuman

    http://tcallaway.com

  4. #4
    Join Date
    Mar 2007
    Posts
    27

    Hi there, but no luck....

    tca and nogdog,

    I get the following error, after placing the code from tca....

    Notice: Undefined index: AgencyName in /var/www/html/samples.php on line 25



    Notice: Undefined index: DescriptionofAgency in /var/www/html/samples.php on line 26
    Thanks for the help and God Bless....

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,252
    Make sure those array indexes exactly match the column names in the table being queried (including upper-/lower-case letters).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #6
    Join Date
    Mar 2007
    Posts
    27

    I checked, but nothing

    Yes I checked those indexes against my column names, but they are the same.....Any thoughts? Thanks and God Bless...

  7. #7
    Join Date
    Mar 2007
    Posts
    27

    I got it, I now see it

    Crazy me, I had to scroll lower....Thanks folks and God Bless....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles