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   包含

    数据库的增删改

原文地址:https://www.cnblogs.com/ITYQ/p/3691408.html