Home  >  Article  >  Database  >  php-PHP菜鸟求解,insert命令总是无法插入mysql数据库

php-PHP菜鸟求解,insert命令总是无法插入mysql数据库

WBOY
WBOYOriginal
2016-06-06 09:40:041107browse

mysqlphp数据库

这是connect.php文件

<code>@mysql_connect("localhost:3306","root","123456") or die("sql连接失败");@mysql_select_db("yhy") or die("yhy连接失败");//mysql_query("set names 'gb2312'");mysql_set_charset("gbk");</code>

?>

这是add.php文件
include("connect.php");//引入连接数据库模块
if(!empty($_POST['sub']))
{

$title=$_POST['title'];
$con=$_POST['con'];
$sql="insert into yhy100(id,title,dates,contents) values(null,'$title',now(),'$con')"."
";
mysql_query($sql);
if(mysql_query($sql))
{
echo "插入成功";
}
else
echo "插入失败";

<code>}   </code>

?>

标题
内容

初学PHP额,连接数据库没问题,但每次点“发表”就提示插入失败,总是无法把数据插入到数据库,这么一个小例程要把我搞死了,求各位大虾指教哇。。。。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn