i have been stuck on this for a little while now i am updating a SQL table through a form in HTML, via PHP and i have the request working when i manually enter the values however when i use $_POST it doesnt work and comes up with a syntax error. i am fairly new to SQL and really appreciate any help given.
//$sql = "UPDATE personnel SET firstName='Lawo', lastName='Fish', email='someThing@aol.col', jobTitle='' WHERE id=4";
$sql = "UPDATE personnel SET firstName=" . $_POST['fname'] . ", lastName=" . $_POST['lname'] . ", email=" . $_POST['email'] . ", jobTitle= " . $_POST['job'] . " WHERE id=" . $_REQUEST['personID'];
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();```
this is my AJAX in script:
```updateFunc.addEventListener('click', function(e) {
fName = document.getElementById('txtFirstName').value;
lName = document.getElementById('txtLastName').value;
email = document.getElementById('txtEmail').value;
job = document.getElementById('txtJobTitle').value;
console.log(job);
$.ajax({
url: "PHP/update.php",
type: 'POST',
dataType: 'json',
data: {
personID: personID,
fname: fName,
lname: lName,
email: email,
job: job,
},```