Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Small PHP Problem --- I think :)

Options
  • 28-04-2005 9:09pm
    #1
    Closed Accounts Posts: 18


    Hi ive been at this friggin PHP for hours trying all sorts of ways to get it working but i cant seem to figure it out. All i want to do is pull the contents of my database table onto a web page. Il post the code below and if anyone can give me a hand il be forever in your debt. :)

    [php]
    <html>

    <body>

    <?php


    $host="localhost";
    $user="*****";
    $password="*****";
    $database="*****";




    mysql_connect($localhost,$user,$password,$database);

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





    // display list of employees

    $result = mysql_query("SELECT * FROM employees");

    while ($myrow = mysql_fetch_array($result)) {

    printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["id"], $myrow["first"], $myrow["last"], $myrow["address"], $myrow["position"]);




    ?>



    </body>

    </html>

    [/php]

    Thanks again ;)


Comments

  • Closed Accounts Posts: 1,891 ✭✭✭Jammer


    no expert but...

    $host="localhost";
    $user="*****";
    $password="*****";
    $database="*****";




    mysql_connect($localhost,$user,$password,$database);


    That looks wrong?


  • Closed Accounts Posts: 18 mind_problems


    Hi thanks for that jammer, ive made the changes but still no luck. Any ideas?


  • Registered Users Posts: 1,268 ✭✭✭hostyle


    Hi ive been at this friggin PHP for hours trying all sorts of ways to get it working but i cant seem to figure it out. All i want to do is pull the contents of my database table onto a web page.

    Rather than us picking through your code to find out what where stuff goes wrong, how about you tell us what doesnt seem to work? :)


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    /nods

    I can see a couple of syntax errors, but you'll have to post up the errors you're getting and we can tell you what's exactly wrong.


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    think you've failed to close off your while loop with its curly brace ... } ??

    then again maybe its early and I should have another coffee...

    as the lads said ... error output would be handy ...


  • Advertisement
  • Closed Accounts Posts: 36 Caixa


    Try this:
    [php]
    <html>

    <body>

    <?php


    $host="localhost";
    $user="*****";
    $password="*****";
    $database="*****";




    $connection = mysql_connect($localhost,$user,$password);

    @$db = mysql_select_db($database,$connection) or die( "Unable to select database");





    // display list of employees

    $result = mysql_query("SELECT * FROM employees");

    while ($myrow = mysql_fetch_array($result)) {

    echo "<a href=\"%s?id=%s\">%s %s</a><br>\n".$PHP_SELF, $myrow["id"]
    .$myrow["first"].$myrow["last"].$myrow["address"].$myrow["position"];

    }




    ?>



    </body>

    </html> [/php]


Advertisement