I have read through many similar questions and had a look at many ajax php tutorials. But I still cannot find for what reason my array is unable to be passed to my PHP.
I post my JS array here:
function passName() {
$.ajax(
{
type: 'POST',
url: 'eDBase.php',
data: 'array=' + arrays,
success: function(){
}
});
}
Where the data is recieved in PHP through:
$arrays = $_POST(['passed'],true);
if ($arrays !== "") {
echo($arrays);
}
$arraypass = "INSERT INTO clientinfo(first_name, last_name, emails)
VALUES($arrays[1],$arrays[2],$arrays[3])";
if($conn->query($arraypass === true)){
echo'Candidate has been added';
}
else{
echo 'Error thrown while adding candidate to database';
}
mysqli_close($conn);
In my PHP preview I get this error thrown: https://gyazo.com/57f7faa9ee0869f56f031112b33d29b6
Full code is here:
PHP: https://codeshare.io/50NQjL HTML: https://codeshare.io/ax1POd
Thanks guys I've been stuck on this issue for about a week now just can't seem to see the problem.
(My PHP code is taking this array and the data from it and then placing it into the database)
EDIT: Code causing error while trying to add to database:
$fname = $_POST['first_name'];
$lname = $_POST['last_name'];
$email = $_POST['email'];
$arraypass = "INSERT INTO clientinfo(first_name, last_name, emails)
VALUES($fname,$lname,$email)";
if($conn->query($arraypass === true)){
echo'Candidate has been added';
}
else{
echo 'Error thrown while adding candidate to database';
}
mysqli_close($conn);