I wondered if anyone could shed some light as to why $newvar5 (integer) is not being passed in the UPDATE statement but is if i explicitly declare $newvar5 = 1; for example. If I don't explicitly declare it I can still echo they type and value of $newvar5 and I get integer and 1 (respectively) where the 1 is the value returned from a select dropdown. Thanks
<?php
$newvar3 = $_POST["area1"];
$newvar4 = $_POST['select1'];
$newvar5 = current($newvar4);
settype($newvar5, "integer");
echo $newvar5;
/*
The above echoes $newvar5 = 1 (it's type is integer) when i select the
first value from the select dropdown but it doesn't work in the update
query shown below. However, it does work if i explicitly code $newvar5=1;
*/
if(isset($_POST['button'])) {
$sql = "UPDATE tblContent SET content = '$newvar3' WHERE contentID='$newvar5'";
if ($conn->query($sql) === TRUE) {
echo "<br>";
echo "Updated Successfully";
} else {
echo "Error updating record: " . $conn->error;
}
}
?>