I am having trouble getting the PHP Code below to work. This is the error I get, when I open the page:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/jsalmon/public_html/a9p2.php on line 131
The text surrounded by "//Error ZONE" is the are where it points to the error
The code is being used to build a table based on a database table.
The table was created like this:
Code:
CREATE TABLE hardware_t (
hdw_part_no char(10) PRIMARY KEY,
hdw_name char(20),
hdw_price numeric(6, 2),
hdw_weight numeric(4, 1),
hdw_picture char(30),
hdw_description varchar);
PHP Code:
<table border = "border">
<caption class = "font"> TOOL LIST AND QUANTITY</caption
<tr><th>Quantity</th><th>Tool</th>Weight</tr>
<!-- Retrieve records from database -->
<?php
$db=pg_connect("dbname=***********");
if (!$db) die("Can't connect to DB.");
$query = "select hdw_name, hdw_price, hdw_weight ";
$query .= "from hardware_t ";
$query .= "order by hdw_name;";
$db_result = pg_query($query);
if (!$db_result)
die("Database error...");
$num = pg_num_rows($db_result);
if ($num == 0) {
echo '<tr><td colspan="2">';
echo 'Query got no rows!</td></tr>';
}
$i = 0;
while ($i < $num) {
$hdw_name = pg_fetch_result
($db_result, $i, 'hdw_name');
$hdw_price = pg_fetch_result
($db_result, $i, 'hdw_price');
$hdw_weight = pg_fetch_result
($db_result, $i, 'hdw_weight');
//Error ZONE
echo "<tr><td align="center"> <input type="text" name= '{$hdw_name}' size="5" maxlength="3"/> </td><td>$hdw_name</td> <td align="right">$hdw_price</td> <td align="right"> $hdw_weight</td></tr>";
//Error ZONE
$i++;
}
?>
<!-- Close out the table and end -->
</table>