Problem with displaying info from a MySQL database
Posted: Mon Apr 05, 2004 1:50 pm
Hey all.
I've been working on trying to show information from a MySQL database for quite awhile and decided that I need some help.
When the code's over, I keep getting:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in **** on line 55
The fields in the my table are:
ID - varchar(128)
Catagory - varchar(128)
Description - varchar(128)
Price - decimal(11,2)
qty - int(11)
image_file - varchar(128)
Anyone have any thoughts
I've been working on trying to show information from a MySQL database for quite awhile and decided that I need some help.
Code: Select all
<? echo "<?xml version="1.0" encoding="utf-8"?" . ">\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Product Catalog </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1 align="center"> Product Catalogue </h1>
<?
error_reporting(E_ALL);
// Set up information to access the database
$host = "****";
$db_user = "****";
$db_password = "****";
$db = $db_user;
//The connection stuff DOES work.
// Establish a connection to database
$connection = mysql_connect($host, $db_user, $db_password) or die("Connection Failed: " . mysql_error());
// Select the database
mysql_select_db($db, $connection) or die("Database selection Failed: " . mysql_error());
// Build SQL statement
$sql = "select * from hardware";
// Run the query
$result = mysql_query($sql, $connection) or die("Query Failed: " . mysql_error());
// Use here document to create table header
// Make sure there is no space after ENDBLOCK, if you copy paste from my
// web site an extra space is inserted after ENDBLOCK delete that extra space
// if you get syntax error on next line
print <<<ENDBLOCK
<form action="MyOrder.php" method="post">
<table border="1" width="100%">
<caption> <strong> $sql </strong></caption>
<tr>
<th width="250"> ID </th>
<th> Catagory </th>
<th width="100"> Description </th>
<th width="25"> Price </th>
<th width="25"> Quantity </th>
<th width="25"> Image </th>
</tr>
ENDBLOCK;
// Show database records
while ( $row = mysql_fetch_array($result)) {
print "<tr>";
print "<td>" . $rowї'ID'] . "</td>";
print "<td>" . $rowї'Catagory'] . "</td>";
print "<td>" . $rowї'Description'] . "</td>";
print "<td align='right'>" . $rowї'Price'] . "</td>";
print "<td align='right'>" . $rowї'qty'] . "</td>";
print "<td align='right'>" . $rowї'image_file'] . "</td>";
print "<td align='center'>" .
"<input type='checkbox' name='item_selectedї]' value='" . $rowїcode] .
"' />";
print "</tr>";
}
print "<tr><td colspan='4' align='right'><input type='submit' value='Order Now' />" .
"</td></tr>";
print "</table>";
print "</form>";
?>
</body>
</html>Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in **** on line 55
The fields in the my table are:
ID - varchar(128)
Catagory - varchar(128)
Description - varchar(128)
Price - decimal(11,2)
qty - int(11)
image_file - varchar(128)
Anyone have any thoughts