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

php?数据插入出错

WBOY
Release: 2016-06-23 13:27:21
Original
909 people have browsed it

$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]  数据里包含一些符号会出错,这个要怎么修改呢??  
Copy after login


回复讨论(解决方案)

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

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

直接打印sql出来

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template