Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Small PHP Problem --- I think :)

  • 28-04-2005 09: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, Registered Users 2 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, Registered Users 2 Posts: 68,173 ✭✭✭✭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, Registered Users 2 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