PHP中执行SQL语句遇到不知什么错误
<?phpinclude('conn.php');$sql="insertintott(id,user,title,content,idate,tui,top)"."va...
<?php
include('conn.php');
$sql="insert into tt (id,user,title,content,idate,tui,top)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now(),default,default`)";
mysql_query($sql);
echo "添加信息成功";
?>
如果我单单在PHPmyadmin上执行这句SQL,是可以写入的
但拿到PHP页面上来就不行了
我检查过数据库链接和写和权限了,都没有问题 ,还是本地调式,
请问是不是我上面的语句有哪里不对的呢? 展开
include('conn.php');
$sql="insert into tt (id,user,title,content,idate,tui,top)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now(),default,default`)";
mysql_query($sql);
echo "添加信息成功";
?>
如果我单单在PHPmyadmin上执行这句SQL,是可以写入的
但拿到PHP页面上来就不行了
我检查过数据库链接和写和权限了,都没有问题 ,还是本地调式,
请问是不是我上面的语句有哪里不对的呢? 展开
3个回答
展开全部
第一,默认值的话不必插入了.
第二, 你仔细看有个`符号..
<?php
include('conn.php');
$sql="insert into tt (id,user,title,content,idate)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now())";
mysql_query($sql);
if($err=mysql_error()) echo "错误!! $err .";
elese echo "添加信息成功";
?>
这要加上错误判断..就OK!!!
第二, 你仔细看有个`符号..
<?php
include('conn.php');
$sql="insert into tt (id,user,title,content,idate)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now())";
mysql_query($sql);
if($err=mysql_error()) echo "错误!! $err .";
elese echo "添加信息成功";
?>
这要加上错误判断..就OK!!!
展开全部
$sql="insert into tt (id,user,title,content,idate,tui,top)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now(),default,default`)";
改成
$sql="insert into tt (id,user,title,content,idate)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now())";
或者
$sql="insert into tt (id,user,title,content,idate,tui,top)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now(),default,default)";
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now(),default,default`)";
改成
$sql="insert into tt (id,user,title,content,idate)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now())";
或者
$sql="insert into tt (id,user,title,content,idate,tui,top)" .
"values (NULL,'dddddd','dtttttttttt','dccccccccccc',now(),default,default)";
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
其实我不建议楼主用insert into XX (123)values(abc)的形式, 建议你用insert into xx set name=value,name1=value2;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询