php连接sql

    $conn = @mysql_connect("localhost","root","root") or die("数据库连接失败,请检查你的网络,稍后再试试");

    mysql_select_db("test");

    mysql_query("set names 'utf8'");

    $sql = "INSERT INTO `test`.`message` (`id`,`user`, `title`, `content`, `lastdate`) VALUES (NULL, '$user', '$title', '$content', now())";    

    mysql_query($sql);

    mysql_close($conn);

    界面-----数据库-----表          必须一致

    now()    获取当前时间

    where 1   始终为真

    or die  屏蔽错误

    include   包含

    数据库的增删改

posted @ 2014-04-26 12:55  光的深处BLOG  阅读(128)  评论(0编辑  收藏  举报