I keep getting the following error when i try to input information to my database.
Error:
Parse error: parse error in /vol/home/wage/public_html/php/handleform.php on line 129
Line 129 is the bit that goes </html> how can that return a parse error?
This is the Code:
<?php
/* programme: handleform.php
* desc: handles data input generated by form.html
*/
?>
<html>
<head><title>HandleForm</title></head>
<body>
<?php
//Trim incoming data
foreach($array as $key => $val) {
$array[$key] = trim($val);
}
//start connection and query
include('blah.inc');
$connection=mysql_connect($host, $user, $password)
or die("couldnt connect to server");
echo "phase one passed <br />";
$db=mysql_select_db($database, $connection)
or die("couldnt connect to database");
echo "phase two passed <br />";
$tablename="organisation";
$query="INSERT into $tablename values
('0', '$array[name]', '$array[address]', '$array[address2]', '$array[address3]','$array[city]', '$array[postcode]','$array[tel]', '$array[fax]', '$array', '$array[aims]', '$array[activities]', '$array[activity2]', '$array[activity3]', '$array[activity4]', '$array[opening_hours]', '$array[referrals]')";
echo "<!-- the query is:<br>$query<br>\n -->";
if (mysql_db_query($database, $query, $connection)) {
echo "<!-- The Query was sucessfully executed <br>\n -->";
} else {
echo "The query could not be executed <br> \n";
}
echo " You entered the following information into the Database.<br />
<table width=\"85%\" border=\"0\">
<tr>
<td width=\"25\"> <strong>Name:</strong> </td>
<td> $array[name] </td>
</tr>
<tr>
<td valign=\"top\"> <strong>Address: </strong></td>
<td> $array[address] <br />";
if ($formData[$x] == '') {
// output
} else {
// don't output
echo "$array[address2]<br />";
}
if ($formData[$x] == '') {
// output
} else {
// don't output
echo "$array[address3]<br />";
}
echo "$array[city] <br />
$array[postcode]
</td>
</tr>
<tr>
<td><strong>Tel: </strong></td>
<td> $array[tel] </td>
</tr>
<tr>
<td> <strong>Fax: </strong></td>
<td> $array[fax] </td>
</tr>
<tr>
<td> <strong>Email: </strong></td>
<td> $array[email] </td>
</tr>
<tr>
<td> <strong>Aims:</strong>:</td>
<td> $array[aims] </td>
</tr>
<tr>
<td valign=\"top\"> <strong>Activities:</strong></td>
<td> <ul>
<li>$array[activities] </li>";
if ($formData[$x] == '') {
// leave empty
} else {
// output
echo "<li>$array[activity2] </li>";
if ($formData[$x] == '') {
// leave empty
} else {
// output
echo "<li>$array[activity3] </li>";
if ($formData[$x] == '') {
// leave empty
} else {
// output
echo "<li>$array[activity4] </li>";
echo "</ul>
</td>
</tr>
<tr>
<td><strong>Opening Hours:</strong> </td>
<td>$array[opening_hours] </td>
</tr>
<tr>
<td> <strong>Referrals: </strong></td>
<td>$array[referral]</td>
</tr>
</table>";
mysql_close($connection);
?>
</body>
</html>
I know im spamming the forum with questions but the manuals and things dont seem to have the answers i need.Double-check your code for missing curly braces. I can see at least one missing at the end of the script, but there might be more.
Error:
Parse error: parse error in /vol/home/wage/public_html/php/handleform.php on line 129
Line 129 is the bit that goes </html> how can that return a parse error?
This is the Code:
<?php
/* programme: handleform.php
* desc: handles data input generated by form.html
*/
?>
<html>
<head><title>HandleForm</title></head>
<body>
<?php
//Trim incoming data
foreach($array as $key => $val) {
$array[$key] = trim($val);
}
//start connection and query
include('blah.inc');
$connection=mysql_connect($host, $user, $password)
or die("couldnt connect to server");
echo "phase one passed <br />";
$db=mysql_select_db($database, $connection)
or die("couldnt connect to database");
echo "phase two passed <br />";
$tablename="organisation";
$query="INSERT into $tablename values
('0', '$array[name]', '$array[address]', '$array[address2]', '$array[address3]','$array[city]', '$array[postcode]','$array[tel]', '$array[fax]', '$array', '$array[aims]', '$array[activities]', '$array[activity2]', '$array[activity3]', '$array[activity4]', '$array[opening_hours]', '$array[referrals]')";
echo "<!-- the query is:<br>$query<br>\n -->";
if (mysql_db_query($database, $query, $connection)) {
echo "<!-- The Query was sucessfully executed <br>\n -->";
} else {
echo "The query could not be executed <br> \n";
}
echo " You entered the following information into the Database.<br />
<table width=\"85%\" border=\"0\">
<tr>
<td width=\"25\"> <strong>Name:</strong> </td>
<td> $array[name] </td>
</tr>
<tr>
<td valign=\"top\"> <strong>Address: </strong></td>
<td> $array[address] <br />";
if ($formData[$x] == '') {
// output
} else {
// don't output
echo "$array[address2]<br />";
}
if ($formData[$x] == '') {
// output
} else {
// don't output
echo "$array[address3]<br />";
}
echo "$array[city] <br />
$array[postcode]
</td>
</tr>
<tr>
<td><strong>Tel: </strong></td>
<td> $array[tel] </td>
</tr>
<tr>
<td> <strong>Fax: </strong></td>
<td> $array[fax] </td>
</tr>
<tr>
<td> <strong>Email: </strong></td>
<td> $array[email] </td>
</tr>
<tr>
<td> <strong>Aims:</strong>:</td>
<td> $array[aims] </td>
</tr>
<tr>
<td valign=\"top\"> <strong>Activities:</strong></td>
<td> <ul>
<li>$array[activities] </li>";
if ($formData[$x] == '') {
// leave empty
} else {
// output
echo "<li>$array[activity2] </li>";
if ($formData[$x] == '') {
// leave empty
} else {
// output
echo "<li>$array[activity3] </li>";
if ($formData[$x] == '') {
// leave empty
} else {
// output
echo "<li>$array[activity4] </li>";
echo "</ul>
</td>
</tr>
<tr>
<td><strong>Opening Hours:</strong> </td>
<td>$array[opening_hours] </td>
</tr>
<tr>
<td> <strong>Referrals: </strong></td>
<td>$array[referral]</td>
</tr>
</table>";
mysql_close($connection);
?>
</body>
</html>
I know im spamming the forum with questions but the manuals and things dont seem to have the answers i need.Double-check your code for missing curly braces. I can see at least one missing at the end of the script, but there might be more.