SQL语法; 检查与MariaDB服务器版本对应的手册[关闭]

我收到以下SQL错误:</ p>


您的SQL语法有错误; 检查与您的MariaDB服务器版本相对应的手册
,以便在 classxiiemail='rajdeep@gmail.com',classxemail ='rajdeep附近使用正确的语法 @ gmail.com'</ code>第5行</ p>
</ blockquote>

我的PHP代码如下所示:</ p>

  $  sql =“UPDATE毕业classxiiclassx SETuniversity ='$ university',college ='$ college',course ='$ course',branch ='$ branch  ',year ='$ year',
school1 ='$ school1',board1 ='$ board1',percentage1 ='$ percentage1',year1 ='$ year1',\ nschool2 ='$ school2',board2 ='$ board2',percentage2 ='$ percentage2',year2 ='$ year2'
WHEREdebondemail ='$ email' ,classxii .email='$ email',classx`email ='$ email'“;

$ res = mysql_query($ sql)or die(mysql_error());
</ code> </ pre>

这里可能出现什么问题?</ p>
</ div>

展开原文

原文

I'm getting the following SQL error:

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 `classxii`.`email`='rajdeep@gmail.com', `classx`.`email`='rajdeep@gmail.com' at line 5

My PHP code looks like:

$sql = "UPDATE `graduation`, `classxii`, `classx` SET `university`='$university', `college`='$college', `course`='$course', `branch`='$branch', `year`='$year', 
`school1`='$school1', `board1`='$board1', `percentage1`='$percentage1', `year1`='$year1', 
`school2`='$school2', `board2`='$board2', `percentage2`='$percentage2', `year2`='$year2' 
WHERE `graduation`.`email`='$email', `classxii`.`email`='$email', `classx`.`email`='$email'";

$res = mysql_query($sql) or die(mysql_error());

What could be the issue here?

douju1865
douju1865 现在停止使用旧的,已弃用的mysql扩展;并使用预准备语句和绑定变量切换到mysqli或pdo
3 年多之前 回复
dongren7374
dongren7374 使用AND/OR组合多个WHERE条件,而不仅仅是以逗号分隔的条件列表
3 年多之前 回复

1个回答



您需要在语句的where部分将逗号更改为AND:</ p>

 在哪里毕业.email='$ email'和classxiiemail` ='$ email'和`classxemail` ='$ email'“; 
</ code> </ pre>

或者如果只搜索其中一个使用OR:</ p>

  WHERE毕业.email='$ email'或classxii.email='$ email'或classx`email ='$ email'“; 
</ code> </ pre>
</ div>

展开原文

原文

You need to change commas to AND in your where part of the statement:

WHERE `graduation`.`email`='$email' AND `classxii`.`email`='$email' AND `classx`.`email`='$email'";

Or if searching only one of them use OR:

WHERE `graduation`.`email`='$email' OR `classxii`.`email`='$email' OR `classx`.`email`='$email'";

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问