向MySQL数据库中添加记录;
以demo数据库,student表为例(有id,stuname,stuAge,tel几个字段)
连接数据库(数据库没有密码)
$mysql=new mysqli("localhost","root","","demo");
if($mysqli->connect_error()){
die("连接数据库失败。。").mysqli->connect_error();
}
echo "连接数据库成功!";
错误写法:
正确的写法
$sql="INSERT INTO student(id,stuname,stuAge,tel)VALUE(1001,'zhangshan',20,'132xxxxxxxx')";