Am trying to insert the values in the mysql database from the variables being posted from the other page and save it in the database butthe code is used to insert the values in mysql database but the query is not working it is showing errors while editing .
Parse error: syntax error, unexpected ''.$Type_of_leave.'' (T_CONSTANT_ENCAPSED_STRING) in C:\wamp\www\saveetha\staff\process_leave.php on line 53
How to make the insertion using the the query New Leave
$con=mysqli_connect("localhost","root","","saveetha");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"INSERT INTO `leave_details`(`leave_id`, `type`, `no_of_days`, `date_from`, `date_till`, `availed_leave`, `leave_reason`, `alternate_date`, `period`, `semester`, `fac_name`, `fac_desg`, `dept`, `approved_authority`) VALUES (
NULL,
"'.$Type_of_leave.'",
"'.$No_of_days.'",
"'.$from.'",
"'.$upto.'",
"'.$Leave_Availed.'",
"'.$Reason_for_Leave.'",
"'.$Alternate_leave.'",
"'.$Period.'",
"'.$Semester.'",
"'.$Fac_name.'",
"'.$Fac_desg.'",
"'.$dept.'",
"'.$Approved_by.'")");
echo 'leave from updated !! ';
mysqli_close($con);
?>
Your quotes are backwards:
mysqli_query($con,"INSERT INTO `leave_details`(`leave_id`, `type`, `no_of_days`, `date_from`, `date_till`, `availed_leave`, `leave_reason`, `alternate_date`, `period`, `semester`, `fac_name`, `fac_desg`, `dept`, `approved_authority`) VALUES (
NULL,
'".$Type_of_leave."',
'".$No_of_days."',
'".$from."',
'".$upto."',
'".$Leave_Availed."',
'".$Reason_for_Leave."',
'".$Alternate_leave."',
'".$Period."',
'".$Semester."',
'".$Fac_name."',
'".$Fac_desg."',
'".$dept."',
'".$Approved_by."')");
The problem is in quotes:
mysqli_query($con,"INSERT INTO `leave_details`(`leave_id`, `type`, `no_of_days`, `date_from`, `date_till`, `availed_leave`, `leave_reason`, `alternate_date`, `period`, `semester`, `fac_name`, `fac_desg`, `dept`, `approved_authority`) VALUES (
NULL,
'$Type_of_leave',
'$No_of_days',
'$from',
'$upto',
'$Leave_Availed',
'$Reason_for_Leave',
'$Alternate_leave',
'$Period',
'$Semester',
'$Fac_name',
'$Fac_desg',
'$dept',
'$Approved_by')");