Reputation: 566
I am trying to update some columns in a row with MySQL in PHP like so:
$updateuser_sql = "
UPDATE `users`
SET
`HeaderPictureID` = $insertid,
`Bio` = '" . myre($_POST['Bio']) . "',
`ContactEmail` = '". myre($_POST['ContactEmail']) ."',
`PhoneNo` = '". myre($_POST['PhoneNo']) ."',
`TwitterHandle` = '". myre($_POST['TwitterHandle']) ."'
WHERE
`UserID` = '{$_SESSION['userID']}'
";
$mysqli->query($updateuser_sql);
if($mysqli->errno) {
$handlerreturn['status'] = 'USER_UPDATE_FAILURE';
console.log('FAILED');
} else {
$handlerreturn['status'] = 'EXEC_SUCCESS';
console.log('WORKED');
}
Unfortunately this doesn't work and I get the log 'FAILED'. How can I find out, more precisely, what is wrong and work to fix the issue? Am I doing something so obviously wrong?
Thanks!
Upvotes: 0
Views: 64
Reputation: 36648
Put this at the end of your page
$_POST["Bio"] = "hi";
$_POST['ContactEmail'] = "cheese";
$_POST['PhoneNo'] = "lion";
$_POST['TwitterHandle'] = "asdl";
$_SESSION['userID'] = "asdf";
$updateuser_sql = "
UPDATE `users`
SET
`HeaderPictureID` = 1,
`Bio` = '" . $_POST['Bio'] . "',
`ContactEmail` = '". $_POST['ContactEmail'] ."',
`PhoneNo` = '". $_POST['PhoneNo'] ."',
`TwitterHandle` = '". $_POST['TwitterHandle'] ."'
WHERE
`UserID` = '{$_SESSION['userID']}'
";
echo $updateuser_sql;
It'll spit out the UPDATE statement that is sent to the database. I didn't see any syntax errors from the above. I suspect the problem has to do with your custom "myre" function.
Upvotes: 1