Changing my codes to prepared statements from mysqli procedural wherein it shows this error after submitting to my php file.
Fatal error: Cannot pass parameter 8 by reference
Here is my php code.
I've just copied this code from my insert data to db without arrays but this php code gets arrays.
<?php
include 'admin/db/database_configuration.php';
if(isset($_POST['submit'])){
if (empty($_POST['title'])){$job_title = 'NULL'; } else{ $job_title ="'". mysqli_real_escape_string($conn, $_POST['title']) . "'";}
if (empty($_POST['desc'])){$job_desc = 'NULL'; } else{ $job_desc ="'". mysqli_real_escape_string($conn, $_POST['desc']) . "'";}
$qualifications ="";
if(isset($_POST["quali"]) && is_array($_POST["quali"])){
$qualifications = implode("\n", $_POST["quali"]);
}
if (empty($_POST['name_cont'])){$name_contact = 'NULL'; } else{ $name_contact ="'". mysqli_real_escape_string($conn, $_POST['name_cont']) . "'";}
if (empty($_POST['contact'])){$contact_num = 'NULL'; } else{ $contact_num ="'". mysqli_real_escape_string($conn, $_POST['contact']) . "'";}
if (empty($_POST['email_add'])){$email_cont = 'NULL'; } else{ $email_cont ="'". mysqli_real_escape_string($conn, $_POST['email_add']) . "'";}
$stmt = $conn->prepare("INSERT INTO `tbljoba` (job_title, job_desc, job_qualifications, cont_name, contact_info, employer_email, job_status) VALUES(?,?,?,?,?,?,?)") or die(mysqli_error($conn));
$stmt->bind_param("sssssss", $job_title, $job_desc, $qualifications, $name_contact, $contact_num, $email_cont, 'pending'); //bind to param
if($stmt->execute()){
$stmt->close();
$conn->close();
echo '<script>alert("Successfully Sent")</script>';
echo '<script>window.location = "employer_contact_us.php"</script>';
}else{
echo '<script>alert("Error")</script>';
}
}
$conn->close();
?>
In this line that I've got an error
$stmt->bind_param("sssssss", $job_title, $job_desc, $qualifications, $name_contact, $contact_num, $email_cont, 'pending'); //bind to param