problem with code very new to php [SOLVED]
Posted: Sun Jan 11, 2004 11:46 am
I have installed an apache server and mysql and am trying to access the database through a page.
my database is called new_db and the table is customers
can some one tell me what i have done wrong here please.
when i run this all i get in the browser is
any help would be greatly appreciated
[Edit: Added php tags for eyecandy. --JAM]
my database is called new_db and the table is customers
can some one tell me what i have done wrong here please.
Code: Select all
<html>
<head>
<title>Retrieve info from database</title>
</head>
<body>
<h2> Customers</h2>
<?php
$linkID = @mysql_connect("localhost", "", "");
mysql_select_db("new_db", $linkID);
$resultID = mysql_query("SELECT * FROM customers", $linkID);
print "<table border=1><tr><th>Customer ID</th>";
print "<th>Name></th><th>Address1</th><th>Address2</th><th>Phone</th>
while ($row = mysql_fetch_row($resultID))
{
print "<tr>";
foreach ($row as $field)
{
print "<td>$field</td>";
}
print "</tr>";
}
print"</table>";
mysql_close($linkID);
?>
</body>
</html>Code: Select all
Customers
"; foreach ($row as $field) { print "$field"; } print ""; } print""; mysql_close($linkID); ?>[Edit: Added php tags for eyecandy. --JAM]