I am trying to add php to a form to populate it from a database, for a homework assignment. I am recieving a parse error "Parse error: syntax error, unexpected end of file in /l7p1.php on line 97". I cannot seem to find my mistake after staring at this file for hours.
I was originally getting "unexpected (T_VARIABLE)" at any point with double quotes, after changing them all to single quotes (hoping there was something to that I didn't understand, because I'm not sure how that changes things) and that moved the error to the final line of code and the "unexpected end of file".
This is the first bit of php, intended to populate a form with items (tools) from a database
<?php
$db=mysli_connect(null,null,null,'weblab')
or die("Can't connect to db:".mysqli_connect_error($db));
$q = "select tool_item_no, tool_name, tool_price, tool_weight";
$q .= "from tool_t";
$q .= "order by tool_name";
$dbResult = mysqli_query($db,$q)
or die("Database query error" . mysqli_error($db));
$num = mysqli_num_rows($dbResult);
if ($num == 0){
echo"<h3>No Data</h3>";
}
while ($row = mysqli_fetch_assoc($dbResult)) {
$tool_item_no = $row["tool_item_no"];
$tmool_name = $row['tool_name'];
$tool_price = $row['tool_price'];
$tool_weight = $row['tool_weight'];
echo "<label for = '$tool_name'>Name : $toolname<br/>Price : $tool_price<br/>Weight : $tool_weight<br/>How many
$tool_name for this order?
<input type = 'text' name = '$tool_name' id = '$tool_item_no' size = ]'5'/></label><br/><br/>
}
?>
This is the second bit of php in my code, intended to populate a drop-down with a list of states from a database
<?php
$db=mysli_connect(null,null,null,'weblab')
or die('Can't connect to
db:'.mysqli_connect_error($db));
$q = 'select state_abbr, state_name ';
$q .= 'from state_t ';
$q .= 'order by state_name;';
$dbResult = mysqli_query($db,$q)
or die('Database query error' .
mysqli_error($db));
$num = mysqli_num_rows($dbResult);
if ($num == 0){
echo '<option value=
'$state_abbr' >$state_name</option>';
echo '<option>Error</option>';
}
while ($row = mysqli_fetch_assoc($dbResult)) {
$state_abbr = $row[state_abbr];
$state_name = $row[state_name];
echo '<option value= '$state_abbr'>
$state_name</option>';
}
?>