php命令插入mysql失败
<?phpinclude("conn.php");//linkmydbif(!empty($_POST['sub'])){$title=$_POST['title'];$...
<?php
include("conn.php"); //link my db
if(!empty($_POST['sub'])){
$title=$_POST['title'];
$con=$_POST['con'];
$sql="insert into `news` (`id`,`title`,`dates`,`contents`) values (null,'$title',now(),'$con')";
mysql_query($sql);
echo "insert success";
}
?>
<form action="add.php" method="post">
标题<input type="text" name="title" ><br>
内容<textarea cols="50" rows="5" name="con"></textarea><br>
<input type="submit" name="sub" value="发表">
</form>
<?php
@mysql_connect("localhost","root","")or die("mysql error");
@mysql_select_db("php")or die("db error");
//mysql_set_charset('gbk');
mysql_query("set names 'gbk'");
?> 展开
include("conn.php"); //link my db
if(!empty($_POST['sub'])){
$title=$_POST['title'];
$con=$_POST['con'];
$sql="insert into `news` (`id`,`title`,`dates`,`contents`) values (null,'$title',now(),'$con')";
mysql_query($sql);
echo "insert success";
}
?>
<form action="add.php" method="post">
标题<input type="text" name="title" ><br>
内容<textarea cols="50" rows="5" name="con"></textarea><br>
<input type="submit" name="sub" value="发表">
</form>
<?php
@mysql_connect("localhost","root","")or die("mysql error");
@mysql_select_db("php")or die("db error");
//mysql_set_charset('gbk');
mysql_query("set names 'gbk'");
?> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询