code returning error
Posted: Mon Sep 05, 2005 3:15 pm
Hi,
My php code is returning an error:
Parse error: parse error, unexpected T_VARIABLE in /home/tomcorker/www/timetables/update.php on line 10
but I've checked the part of the script it's refering to an can't see anything wrong.
Can anybody else see anythig wrong with it?
Thanks,
Tom
My php code is returning an error:
Parse error: parse error, unexpected T_VARIABLE in /home/tomcorker/www/timetables/update.php on line 10
but I've checked the part of the script it's refering to an can't see anything wrong.
Code: Select all
<html>
<head>
</head>
<body>
<? php
$host = "localhost";
$user = "tomcorker";
$pass = "39sc8up3";
$db = "tomcorker_db";
$num = $_POST['loop'];
$lowerLimit = 1;
while ($lowerLimit <= $num) {
// get form input
// check to make sure it's all there
// escape input values for greater safety
$toc = empty($_POST['toc$lowerLimit']) ? die ("ERROR: Enter a toc") : mysql_escape_string($_POST['toc$lowerLimit']);
$timetable = empty($_POST['timetable$lowerLimit']) ? die ("ERROR: Enter an timetable") : mysql_escape_string($_POST['timetable$lowerLimit']);
$route = empty($_POST['route$lowerLimit']) ? die ("ERROR: Enter an route") : mysql_escape_string($_POST['route$lowerLimit']);
$url = empty($_POST['url$lowerLimit']) ? die ("ERROR: Enter an url") : mysql_escape_string($_POST['url$lowerLimit']);
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "INSERT INTO timetables (toc, timetable, route, url) VALUES ('$toc', '$timetable', '$route', '$url')";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// print message with ID of inserted record
echo "New record inserted with ID ".mysql_insert_id();
// destroy more than one variable
unset($toc, $timetable, $route, $url);
// close connection
mysql_close($connection);
$lowerLimit++;
}
?>
</body>
</html>Thanks,
Tom