php插入一条数据
<?php$dbhost='localhost';$dbuser='root';//你的mysql用户名$dbpass='root';//你的mysql密码$dbname...
<?php
$dbhost = 'localhost';
$dbuser = 'root'; //你的mysql用户名
$dbpass = 'root'; //你的mysql密码
$dbname = 'shenmor'; //你的mysql库名
$title = $_GET['t'];//GET方法为URL参数传递
$key = $_GET['k'];
//连接本地数据库
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if ($conn) {
echo "连接数据库成功";
} else {
echo "连接数据库失败";
}
//打开数据库
mysql_select_db($dbname,$conn);
//插入数据
$sql="INSERT INTO wechat (title,key)VALUES('title','key') ";
$result=mysql_query($sql,$conn)or die(mysql_error());
echo "<br/>插入成功";
//关闭数据库
mysql_close($conn);
?>
这块哪里出错了 显示的是:连接数据库成功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
'key)VALUES('title','key')' at line 1 展开
$dbhost = 'localhost';
$dbuser = 'root'; //你的mysql用户名
$dbpass = 'root'; //你的mysql密码
$dbname = 'shenmor'; //你的mysql库名
$title = $_GET['t'];//GET方法为URL参数传递
$key = $_GET['k'];
//连接本地数据库
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if ($conn) {
echo "连接数据库成功";
} else {
echo "连接数据库失败";
}
//打开数据库
mysql_select_db($dbname,$conn);
//插入数据
$sql="INSERT INTO wechat (title,key)VALUES('title','key') ";
$result=mysql_query($sql,$conn)or die(mysql_error());
echo "<br/>插入成功";
//关闭数据库
mysql_close($conn);
?>
这块哪里出错了 显示的是:连接数据库成功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
'key)VALUES('title','key')' at line 1 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询