Insert into database PHP problem
Posted: Thu Feb 26, 2009 6:25 am
Hi
I'm currently writing a PHP script to insert some data into a database I've created. The data is taken from a HTML form and is passed to this script which in turn inserts it into the relevant tables of my database. Very simple indeed...
Here is the code:
Once I submit the form on the other page this script runs but I always get this error message:
Parse error: syntax error, unexpected $end in C:\Users\Jamie\Desktop\xampp\htdocs\xampp\Asset Tracking System\insert_Antrim.php on line 24
Does anyone know why I'm getting this? I've been looking at this same code for ages but just cant work it out.
Thanks for any help.
I'm currently writing a PHP script to insert some data into a database I've created. The data is taken from a HTML form and is passed to this script which in turn inserts it into the relevant tables of my database. Very simple indeed...
Here is the code:
Code: Select all
<?php
$mysqli = mysqli_connect("localhost", "my_username", "my_password", "my_database");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
} else {
$sql = "INSERT INTO salesperson (`salesman_no`, `branch_no`, `first_name`, `last_name`)
VALUES ('".$POST["salesman_no"]."',\'001\','".$POST["firstname"]."','".$POST["lastname"]."');
INSERT INTO hhc (`hhc_asset_no`, `salesman_no`)
VALUES ('".$POST["hhc_no"]."','".$POST["salesman_no"]."')
INSERT INTO printer (`printer_asset_no`, `salesman_no`)
VALUES ('".$POST["printer_no"]."','".$POST["salesman_no"]."')";
$res = mysqli_query($mysqli, $sql);
if ($res === TRUE) {
echo "A record has been inserted.";
} else {
printf("Could not insert a record: %s\n, mysqli_error($mysqli));
}
mysqli_close($mysqli);
}
?>Parse error: syntax error, unexpected $end in C:\Users\Jamie\Desktop\xampp\htdocs\xampp\Asset Tracking System\insert_Antrim.php on line 24
Does anyone know why I'm getting this? I've been looking at this same code for ages but just cant work it out.
Thanks for any help.