Home >Backend Development >PHP Tutorial >很简单的一个insert有关问题,但是就是有有关问题,请大家帮忙看看到底哪里有有关问题
很简单的一个insert问题,但是就是有问题,请大家帮忙看看到底哪里有问题
insert into rc(zjbs,zjdm,gzbj,xingming,sex,minzu,zzmm,csri,csd,byyx,bysj,sxzy,whcd,xw,gzdw,gzsj,dwlb,dwxz,xzzw,xzjb,cszy,gkhy,jszc,zgzt,tel,zip,ys,ggqjb,ttnf,ttje,tgnf,sbnf,bdnf,jbzn,hgnf,chcl,lhjt,gzjl,tcsj,dblz,zxcg,isvalid,pic) values( 'dsaf ', 'asdf ', 'sdfasd ', 'asdf ', '1 ', '回族 ', 'asdf ', 'asdf ', 'asdf ', 'asdf ', 'asdf ', 'fasdf ', '高中 ', 'asf ', 'asdf ', 'asfd ', 'asdf ', 'asdf ', 'asd ', 'asdf ', 'asdf ', 'ffasdf ', '高级 ', 'asdf ', 'asdf ', 'asdf ', 'asdf ', 'asfd ',asdf,asdf,tgnf,sbnf,asdf,asdf,asdf, 'asdf ', 'asdf ', 'asdf ', 'asdf ', 'asdf ', 'asdf ', '0 ', '1186039175.gif ')
打印出来是这样的
$SQL= "insert into rc( ";
$SQL=$SQL. "zjbs,zjdm,gzbj,xingming,sex,minzu,zzmm,csri,csd,byyx,bysj,sxzy,whcd,xw,gzdw,gzsj,dwlb,dwxz,xzzw,xzjb,cszy,gkhy,jszc,zgzt,tel,zip,ys,ggqjb,ttnf,ttje,tgnf,sbnf,bdnf,jbzn,hgnf,chcl,lhjt,gzjl,tcsj,dblz,zxcg,isvalid,pic ";
$SQL=$SQL. ") values( ";
$SQL=$SQL. " '$zjbs ', '$zjdm ', '$gzbj ', '$xingming ', '$sex ', '$minzu ', '$zzmm ', '$csri ', '$csd ', '$byyx ', '$bysj ', '$sxzy ', '$whcd ', '$xw ', '$gzdw ', '$gzsj ', '$dwlb ', '$dwxz ', '$xzzw ', '$xzjb ', '$cszy ', '$gkhy ', '$jszc ', '$zgzt ', '$tel ', '$zip ', '$ys ', '$ggqjb ',$ttnf,$ttje,tgnf,sbnf,$bdnf,$jbzn,$hgnf, '$chcl ', '$lhjt ', '$gzjl ', '$tcsj ', '$dblz ', '$zxcg ', '0 ', '$pic ' ";
$SQL=$SQL. ") ";
这里是我的组合
打印出来的sql在mysql得那个可视化界面里面能够直接插入数据库没有任何异常
但是用php来执行的话,就是死活都不成功
大家帮我看看为什么
先感谢了
在线等
------解决方案--------------------
1、报错没?什么错?
2、最好还是把你插入这段代码贴上来
------解决方案--------------------
echo mysql_error();
看看是什么错误
------解决方案--------------------
$SQL= "insert into rc( ";
$SQL=$SQL. "zjbs,zjdm,gzbj,xingming,sex,minzu,zzmm,csri,csd,byyx,bysj,sxzy,whcd,xw,gzdw,gzsj,dwlb,dwxz,xzzw,xzjb,cszy,gkhy,jszc,zgzt,tel,zip,ys,ggqjb,ttnf,ttje,tgnf,sbnf,bdnf,jbzn,hgnf,chcl,lhjt,gzjl,tcsj,dblz,zxcg,isvalid,pic ";
$SQL=$SQL. ") values( ";
$SQL=$SQL. " '$zjbs ', '$zjdm ', '$gzbj ', '$xingming ', '$sex ', '$minzu ', '$zzmm ', '$csri ', '$csd ', '$byyx ', '$bysj ', '$sxzy ', '$whcd ', '$xw ', '$gzdw ', '$gzsj ', '$dwlb ', '$dwxz ', '$xzzw ', '$xzjb ', '$cszy ', '$gkhy ', '$jszc ', '$zgzt ', '$tel ', '$zip ', '$ys ', '$ggqjb ', '$ttnf ', '$ttje ', 'tgnf ', 'sbnf ', '$bdnf ', '$jbzn ', '$hgnf ', '$chcl ', '$lhjt ', '$gzjl ', '$tcsj ', '$dblz ', '$zxcg ', '0 ', '$pic ' ";
$SQL=$SQL. ") ";
------解决方案--------------------
gkhy ', '$jszc ', '$zgzt ', '$tel ', '$zip ', '$ys ', '$ggqjb ',$ttnf,$ttje,tgnf,sbnf,$bdnf,$jbzn,$hgnf,
这一行中 tgnf,sbnf 变量没有加$,也没加引号!