if(isset($_POST['addreservation']) and $_POST['addreservation'] == 'Add'){
include $_SERVER['DOCUMENT_ROOT'] . '/TattooSite/include/db.inc.php';
$username=$_SESSION['username']; //Geting the id of loggedin client
$result=mysqli_query($link, "SELECT id FROM client_tbl WHERE user_name='$username' ");
if(!$result){
$error='Error identifying user ' . mysqli_error($link);
include $_SERVER['DOCUMENT_ROOT'] . '/TattooSite/include/error.html.php';
exit();
}
$row=mysqli_fetch_array($result);
$clientid=$row['id'];
//Geting the values generated in reservation form
$id=mysqli_real_escape_string($link, $_POST['id']);
$tattoo=mysqli_real_escape_string($link, $_POST['tattoo']);
$price=mysqli_real_escape_string($link, $_POST['price']);
$date=mysqli_real_escape_string($link, $_POST['date']);
$width=mysqli_real_escape_string($link, $_POST['width']);
$hight=mysqli_real_escape_string($link, $_POST['hight']);
$sql="INSERT INTO tattoo_tbl SET description='$tattoo', width='$width', hight='$hight'";
if(!mysqli_query($link, $sql)){
$error='Error inserting new tattoo parameters: ' . mysqli_error($link);
include $_SERVER['DOCUMENT_ROOT'] . '/TattooSite/include/error.html.php';
exit();
}
$tattooid = mysql_insert_id();
$sql1="INSERT INTO reservation_tbl SET tattoo_id='$tattooid', client_id='$tattooid', date='$date', price='$price'";
if(!mysqli_query($link, $sql1)){
$error='Error inserting new reservation parameters: ' . mysqli_error($link);
include $_SERVER['DOCUMENT_ROOT'] . '/TattooSite/include/error.html.php';
exit();
}
header('Location: .');
exit();
The problem is that when I select the records from database, client_id is '0' all the time. I think mysqli_insert_id() is not storing the id from the previous query. Please any ideas what maid be the problem.