Rumah > pembangunan bahagian belakang > tutorial php > Unknown column 'name' in 'field list ; please help me

Unknown column 'name' in 'field list ; please help me

WBOY
Lepaskan: 2016-06-23 13:42:48
asal
1290 orang telah melayarinya

<?php $conn = mysql_connect("localhost", "root", "");/*echo"$stm"*/if (!$conn)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("root",$conn)or die(mysql_error());mysql_query('set names GB2312');$sql="insert into shopsystem(name,tel,email,QQ,addr,sex,brandname,commoditybrand,productID,ordername,shopname,shopaddr,invoicenumber,purchasingdate)values('$name','$tel','$email','$QQ','$addr','$sex','$brandname','$commoditybrand','$productID','$ordername','$shopname','$shopaddr','$invoicenumber','$purchasingdate')";if (!mysql_query($sql,$conn))  {  die ('Error: ' . mysql_error());  }mysql_close($conn);?>
Salin selepas log masuk


Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 2


回复讨论(解决方案)

错误提示有两个?
echo $sql; 贴出结果看看。

Unknown column 'name' in 'field list ;
name 字段不存在,请检查

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 2

$sql="insert into shopsystem(name,tel,email,QQ,addr,sex,brandname,commoditybrand,productID,ordername,shopname,shopaddr,invoicenumber,purchasingdate)
values('$name','$tel','$email','$QQ','$addr','$sex','$brandname','$commoditybrand','$productID','$ordername','$shopname','$shopaddr','$invoicenumber','$purchasingdate')";
if (!mysql_query($sql,$conn))

values 前加个空格试试。

字段错误 也有可能是 单引号问题,数字、日期等不加引号

shopsystem(name,tel,email,QQ,addr,sex,brandname,commoditybrand,productID,ordername,shopname,shopaddr,invoicenumber,purchasingdate)这里面的字段全用`name`,`tel`,这样的试试,Esc下面的那个键
Salin selepas log masuk

单引号问题吧。。
建议用拼接

$sql="insert into shopsystem(name,tel,email,QQ,addr,sex,brandname,commoditybrand,productID,ordername,shopname,shopaddr,invoicenumber,purchasingdate)values('".$name."','".$tel."','    ....
Salin selepas log masuk

sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan