先上代码(php):
$id_card="";
$sql = "select * from people where id_card=".$id_card;
看似有值,但是这个sql是这样的:
select * from people where id_card=
当然会语法错误。
这时候要把$id_card当作字符串处理:
$sql = "select * from people where id_card= ' ".$id_card." ' "; (多余空格自行删除)
本文共 291 字,大约阅读时间需要 1 分钟。
先上代码(php):
$id_card="";
$sql = "select * from people where id_card=".$id_card;
看似有值,但是这个sql是这样的:
select * from people where id_card=
当然会语法错误。
这时候要把$id_card当作字符串处理:
$sql = "select * from people where id_card= ' ".$id_card." ' "; (多余空格自行删除)
转载于:https://www.cnblogs.com/alanleung/p/7411925.html