Home >Backend Development >PHP Tutorial >php?数据插入出错

php?数据插入出错

WBOY
WBOYOriginal
2016-06-23 13:27:21942browse

$sql=sprintf("insert into ca_tips (%s,%s) value (%s,'%s')",$arr[0], $arr[1],$v[0],$v[1]);//当$v[1]=I'm sure 时,sql会出错 //$v[1]  数据里包含一些符号会出错,这个要怎么修改呢??  


回复讨论(解决方案)

改个名字吧,字段名最好别有特殊符号。

$sql=sprintf("insert into ca_tips (%s,%s) value (%s,'%s')",$arr[0], $arr[1],$v[0], addslashes($v[1]));

直接打印sql出来

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP中的类型Next article:php代码上线,实现版本切换