$name=$_GET['name'];
if($name){
echo "欢迎你,".$name;
}
else{
header("Location:index.php");
}
include('conn.php');
$pid=$_GET['id'];
$price=$_GET['price'];
$pname=$_GET['pname'];
$sql="INSERT INTO table_dan(`pid`,`pname`,`price`,`num`) values('$pid','$pname','$price','$name')";
$rs=mssql_query($sql,$conn);
//echo mssql_error();
echo $sql;
?>
页面上出现的是:
欢迎你,hwmilmf
Warning: mssql_query() [function.mssql-query]: message: '`' 附近有语法错误。 (severity 15) in D:\Server\www\ok\buy.php on line 14
Warning: mssql_query() [function.mssql-query]: Query failed in D:\Server\www\ok\buy.php on line 14
INSERT INTO table_dan(`pid`,`pname`,`price`,`num`) values('1','红烧鱼','20','hwmilmf')
不知道什么原因,查询其它表是可以的,就是不能增加到这个表中。奇怪了。
在php上新增记录到mssql 出现问题
答案:2 悬赏:30 手机版
解决时间 2021-03-08 09:36
- 提问者网友:你挡着我发光了
- 2021-03-08 04:39
最佳答案
- 五星知识达人网友:一把行者刀
- 2021-03-08 05:48
你查下,看你表中的数据类型与你插入的数据类型是否一致。已经提示了:“'`' 附近有语法错误”。
全部回答
- 1楼网友:猎心人
- 2021-03-08 06:23
<%
'declare the variables
dim
connection
dim recordset
dim sql
'declare the sql statement that will query the database
sql="insert into customers (customerid,companyname,"
sql=sql & "contactname,address,city,postalcode,country)"
sql=sql & " values "
sql=sql & "('" & request.form("custid") & "',"
sql=sql & "'" & request.form("compname") & "',"
sql=sql & "'" & request.form("contname") & "',"
sql=sql & "'" & request.form("address") & "',"
sql=sql & "'" & request.form("city") & "',"
sql=sql & "'" & request.form("postcode") & "',"
sql=sql & "'" & request.form("country") & "')"
'create an instance of the ado connection and recordset objects
set connection = server.createobject("adodb.connection")
'open the connection to the database
connection.open
"dsn=dsn_name;uid=user_name;pwd=password;database=database_name"
on error resume next
conn.execute sql,recaffected
if err<>0 then
response.write("no update permissions!")
else
response.write("" & recaffected & " record added")
end if
connection.close
set connection=nothing
%>
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯