Re: help with script!!!

From: Date: Sun, 02 Feb 2003 07:53:32 +0000
Subject: Re: help with script!!!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-133974@lists.php.net to get a copy of this message
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

« previous php.general (#133974) next »