php - mysql update query is not working -
i want update email field php sql doesn't seems working.
$email2 = "'testing@example.com'"; $id = "'1'"; $query = "update `users` set `email` = $email2 `id` = $id"; echo $query; if ($stmt = mysqli_prepare($connection, $query)) { /* execute statement */ mysqli_stmt_execute($stmt); /* bind result variables */ mysqli_stmt_bind_result($stmt); /* fetch values */ while (mysqli_stmt_fetch($stmt)) { } /* close statement */ mysqli_stmt_close($stmt); } mysqli_close($connection);
i'm new programming. hope guys can me find mistake. use mamp on mac. php version: 5.6.7.
since providing in query self. try this:-
$email2 = "testing@example.com"; // remove '' quote $id = "1"; // remove '' quote $query = "update `users` set `email` = $email2 `id` = $id"; $result = mysqli_query($connection,$query) or die(mysqli_error($connection)); if($result){ // stuff } mysqli_close($connection);
note:- try read mysqli_*
prepare()
, bind_result()
carefully. use it. don't go blindly. thanks. start step step.
Comments
Post a Comment