Possible Duplicate:
Reference - What does this error mean in PHP?
Good Day,
I have a html form that has an input box, a submit button and a result box. On submit, the input is sent to the php file where a query is done and I'm trying to echo back a field from the database back to the result box, which I've called 'answer' in my form.
Here is my php file:
<?php
$hostname = 'myhost.com';
$username = 'ratetable';
$password = 'mypassword';
$term = (int) $_GET['term'];
try {
$dbh = new PDO("mysql:host=$hostname;dbname=ratetable", $username, $password);
echo 'Connected to database<br />';
foreach($db->query('SELECT * FROM rates WHERE mileage<=$term' DESC LIMIT 1) as $row) {
echo "<input type='text' name='answer' value='$row['ratepermile']'>";
}
}
?>
However, I'm getting "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING" on the line where I want to echo a field (ratepermile) from the row in the database back to the 'answer' text box. I did some checking and found that this error means that I'm missing some closing bracket or something like that but I'm not seeing what it's choking on.
Can someone please tell me what is creating the problem?
Thanks for having a look.