Wookie
11-02-04, 17:31
Needed to write myself something figured id learn php and mysql while im at it. Anyway ive done this before but im getting an error on this page for some reason.
Heres my Form
<form METHOD=POST ACTION="addnew.php">
<input type="hidden" name="id" value="NULL">
Start Place: <INPUT TYPE="TEXT" NAME="startvar"><br>
Destination: <INPUT TYPE="TEXT" NAME="DESTINATION"><br>
Miles: <INPUT TYPE="TEXT" NAME="MILES"><br>
Date: <INPUT TYPE="TEXT" NAME="DATE"><br>
<INPUT TYPE="SUBMIT" VALUE="SUBMIT">
</FORM>
Pretty simple, now heres the code that gets it.
$id = $_POST['id'];
$startvar1 = $_POST['startvar'];
$dest = $_POST['destination'];
$miles = $_POST['miles'];
$dt = $_POST['date'];
well ive done it before and it was pretty simple but I am getting this error
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
which points right to the ID one, if I take the ID out and the NULL out of the form it does same thing except points to startvar1
all im doing is passing a bunch of letters and a date in the form.
if anyone has any ideas I would appreciate it. Just worked 9.5 hours now off to programming class for 2 more hours :)
anyway here is the entire thing
<?php
if (isset($_COOKIE["validated"])){
$cookieinfo = $_COOKIE["validated"];
}
else
{
echo 'Sorry you are not authorized to view this page';
}
if ($cookieinfo == 'myval'){
$DBhost = 'localhost';
$DBuser = 'localuser';
$DBpass = 'localpassword';
$DBName = 'localdb';
$table = 'miles';
mysql_connect($DBhost,$DBuser,$DBpass) or die('Unable to connect to database');
@mysql_select_db('$DBName') or die('Unable to select database $DBName');
$id = $_POST['id'];
$startvar1 = $_POST['startvar'];
$dest = $_POST['destination'];
$miles = $_POST['miles'];
$dt = $_POST['date'];
$sqlquery = "INSERT INTO $table VALUES('$id','$start','$dest','$miles','$dt')";
$results = mysql_query($sqlquery);
mysql_close():
header('location:myfile.php');
}
?>
Heres my Form
<form METHOD=POST ACTION="addnew.php">
<input type="hidden" name="id" value="NULL">
Start Place: <INPUT TYPE="TEXT" NAME="startvar"><br>
Destination: <INPUT TYPE="TEXT" NAME="DESTINATION"><br>
Miles: <INPUT TYPE="TEXT" NAME="MILES"><br>
Date: <INPUT TYPE="TEXT" NAME="DATE"><br>
<INPUT TYPE="SUBMIT" VALUE="SUBMIT">
</FORM>
Pretty simple, now heres the code that gets it.
$id = $_POST['id'];
$startvar1 = $_POST['startvar'];
$dest = $_POST['destination'];
$miles = $_POST['miles'];
$dt = $_POST['date'];
well ive done it before and it was pretty simple but I am getting this error
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
which points right to the ID one, if I take the ID out and the NULL out of the form it does same thing except points to startvar1
all im doing is passing a bunch of letters and a date in the form.
if anyone has any ideas I would appreciate it. Just worked 9.5 hours now off to programming class for 2 more hours :)
anyway here is the entire thing
<?php
if (isset($_COOKIE["validated"])){
$cookieinfo = $_COOKIE["validated"];
}
else
{
echo 'Sorry you are not authorized to view this page';
}
if ($cookieinfo == 'myval'){
$DBhost = 'localhost';
$DBuser = 'localuser';
$DBpass = 'localpassword';
$DBName = 'localdb';
$table = 'miles';
mysql_connect($DBhost,$DBuser,$DBpass) or die('Unable to connect to database');
@mysql_select_db('$DBName') or die('Unable to select database $DBName');
$id = $_POST['id'];
$startvar1 = $_POST['startvar'];
$dest = $_POST['destination'];
$miles = $_POST['miles'];
$dt = $_POST['date'];
$sqlquery = "INSERT INTO $table VALUES('$id','$start','$dest','$miles','$dt')";
$results = mysql_query($sqlquery);
mysql_close():
header('location:myfile.php');
}
?>