On Sat, 1 Feb 2003, Karl James wrote:

> Hello guys and gals!!!
> 
> can you tell me why i can't get this script to print my 
> table....
> 
> thanks Karl 
> 
> please check out the code below
> obviously i left my username and passwords blank :-)
> 
>  
> -----------------------------------------------------------------------------
> --------------------------------------------------------
> <?
> $sqlhost = "localhost";
> $sqllogin = "login";
> $sqlpw = "password"; 
> $sqldb = "database table name";
> (@!mysql_pconnect($sql[localhost], $sql[wedbd13], $sql[webdb13])) {
> die(mysql_error()); }
> (@!mysql_select_db($sql[wedbd13])) { die(mysql_error()); }
> $result = mysql_query("SELECT * FROM `assignment_one`");
> while($array = mysql_fetch_array($result)) {
> echo("| %s | %s | %s | %s | %s |<br />", $array[id], $array[username],
> $array[password], $array[status], $array[notes]);
> }
> ?>


Maybe this will help:

<?php
if (!mysql_connect($host, $user, $pass)) {
    echo "Could not connect to MySQL";
    exit;
}
if (!mysql_select_db($dbname)) {
    echo "Could not select database ($dbname) : " . mysql_error();
    exit;
}

$sql = "SELECT id,username,password,status,notes 
        FROM assignment_one";
$result = mysql_query($sql);

if (!$result) {
    echo "Could not run query ($sql) : " . mysql_error();
    exit;
}

while ($row = mysql_fetch_assoc($result)) {
    extract($row);

    echo "| $id | $username | $password | $status | $notes |<br />\n";
}
?>

Regards,
Philip


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to