Hi, I am working on an hotel booking system for a small hotel.I finally found a nice tutorial on HTML.it.It is in Italian but that's not a problem for me as Italian is my mother tongue.The site consists of the usual tables like clients, reservations, etc.I ran all the scripts from the command line and everything works fine. I still am not too sure of what I am doing but I figured that once I deliver the finished site to the hotel people, they are not going to want to fiddle with the command line, phpMyAdmin,MySQL etc.when they have to insert a reservation.So I started creating some user interface like a form to insert clients data as below.The problem is that last insert id business which is very important for the site to work.I searched the Internet but could not find a solution, I think the problem is that insert_id into @codeclient.Can you help me?this is the code involved.
INSERT INTO client SET
nominativo = 'Rossi Mario',
indirizzo = via Manzi 2 00153 Rome,
telefono ='06 86123920';
SELECT_LAST_INSERT_ID() INTO @codCliente;
<table width="300" border="0" align="center" cellspacing="1" cellpadding="0">
<tr><td><form name="form1" method="post" action="insert_ac.php">
<table width="100" border="0" cellspacing="1" cellpadding="3">
<tr><td colspan="3"><strong>Insert Data into MySQL Database</strong></td></tr>
<tr><td width="71">Nominativo</td>
<td width="6">:</td>
<td width="301"><input name="nominative" type="text" id="nominative"></td>
</tr>
<tr><td>Indirizzo</td>
<td>:</td>
<td><input name="indirizzo" type="text" id="indirizzo</td>
</tr>
<tr>
<td>Telefono</td>
<td>:</td>
<td><input name="telefono" type="text" id="telefono></td>
</tr>
<tr><td colspan="3" align="center"><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="Fiorentino##"; // Mysql password
$db_name="hotel"; // Database name
$tbl_name="clienti"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$nominativo=$_POST['nominativo'];
$indirizzo=$_POST['indirizzo'];
$telefono=$_POST['telefono'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name SET(nominativo, indirizzo, telefono)VALUES('$nominativo', '$indirizzo', '$telefono')";
SELECT LAST_INSERT_ID() INTO @codCliente;
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='insert.php'>Back to main page</a>";
}
else {
echo "ERROR";
}
?>
<?php
// close connection
mysql_close();
?>
And this is the error I get:Parse error: syntax error, unexpected 'LAST_INSERT_ID' (T_STRING) in C:\inetpub\wwwroot\Hotel Site\insert_ac.php on line 20