Fatal error: Uncaught mysqli_sql_exception: You have an error in your
SQL syntax; check the manual that corresponds to your MariaDB server
version for the right syntax to use near ‘WHERE SET numb=’61’ WHERE
ID=’#ID” at line 1 in C:xampphtdocsweb_2.1phpsend.php:20 Stack
trace: #0 C:xampphtdocsweb_2.1phpsend.php(20):
mysqli_query(Object(mysqli), ‘UPDATE depo…’) #1 {main} thrown in
C:xampphtdocsweb_2.1phpsend.php on line 20
I trying to add numbers in mysql database, for example:
session_start();
include('info.php');
$add = $_POST['submit'];
$ID=$_SESSION['ID'];
$query="SELECT numb FROM `prof` WHERE ID='$ID'";
$result=mysqli_query($conn, $query);
$pr=mysqli_num_rows($result);
if($pr>0){
$row=mysqli_fetch_array($result);
$i=$row['numb'];
$total = $i + $add;
$querys="UPDATE `prof` WHERE SET numb='$total' WHERE ID='$ID'";
$result=mysqli_query($conn, $querys);
header("Location: send.php");
} else{
$sql="INSERT INTO `prof` (ID, numb)VALUES($ID, $add)";
$result=mysqli_query($conn, $sql);
header("Location: /web_2.1/profile.php");
}
but after sending first query I can’t send second one and getting this error
2
Answers
This query has two WHERE keywords, that is not valid SQL, there can only be one WHERE:
What you are looking for seems to be an AND condition, replacing the 2nd WHERE with an AND keyword instead:
Try with below query string