数据库插入错误php
向数据库插入数据总是错误不知为什么这是数据库:这是php代码:<?phpsession_start();header("content-type:text/html;ch...
向数据库插入数据总是错误不知为什么 这是数据库:
这是php代码:
<?php
session_start();
header("content-type:text/html;charset=utf-8");
$content = $_POST["content"];
$connect_id = $_POST["id"];
$username = $_SESSION['username'];
$currentDate = date("Y-m-d H:i:s");
$ip = $_SERVER["REMOTE_ADDR"];
$state = "未审核";
$conn = mysql_connect("localhost", "root", "") or die("数据库连接失败".mysql.error());
mysql_select_db("ausspeace") or die ("没有数据库".mysql.error());
mysql_query("set names 'utf8' ");
$sql = "insert into speace_comment(connect_id, username, content, publish_time, state, ip) values('$connect_id', '$username', $content', '$currentDate', '$state', '$ip')";
if (mysql_query($sql)) {
echo "添加评论成功!<a href='myself/album-myself1.php'>返回";
}else{
echo "添加评论失败,请重新添加。<a href='myself/album-myself1.php'>返回";
};
?>
请问问题出在哪 该怎么改? 展开
这是php代码:
<?php
session_start();
header("content-type:text/html;charset=utf-8");
$content = $_POST["content"];
$connect_id = $_POST["id"];
$username = $_SESSION['username'];
$currentDate = date("Y-m-d H:i:s");
$ip = $_SERVER["REMOTE_ADDR"];
$state = "未审核";
$conn = mysql_connect("localhost", "root", "") or die("数据库连接失败".mysql.error());
mysql_select_db("ausspeace") or die ("没有数据库".mysql.error());
mysql_query("set names 'utf8' ");
$sql = "insert into speace_comment(connect_id, username, content, publish_time, state, ip) values('$connect_id', '$username', $content', '$currentDate', '$state', '$ip')";
if (mysql_query($sql)) {
echo "添加评论成功!<a href='myself/album-myself1.php'>返回";
}else{
echo "添加评论失败,请重新添加。<a href='myself/album-myself1.php'>返回";
};
?>
请问问题出在哪 该怎么改? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询