$con=new mysqli("localhost","root","","classdb");
$con->set_charset('utf8');
if($con->connect_error){
die('连接数据库失败');}
$sql = "insert into student (xuehao,password) vlaues('$email','$password')";
if(mysqli_query($con,$sql)){
echo "成功插入";
}else{echo "插入失败";
}
<?php
$con=new mysqli("localhost","root","","classdb");
$con->set_charset('utf8');
if($con->connect_error){
die('è¿æ¥æ°æ®åºå¤±è´¥');}
$sql = "insert into student (xuehao,password) vlaues('".$email."','".$password."')";
if(mysqli_query($con,$sql)){
echo "æåæå ¥";
}else{echo "æå ¥å¤±è´¥";
}
?>
$con=new mysqli("localhost","root","","classdb");
$con->set_charset('utf8');
if($con->connect_error){
die('è¿æ¥æ°æ®åºå¤±è´¥');}
$sql = "insert into student (xuehao,password) vlaues('".$email."','".$password."')";
if(mysqli_query($con,$sql)){
echo "æåæå ¥";
}else{echo "æå ¥å¤±è´¥";
}
?>
è¿æ ·è¯è¯
ä¸æ ·æ¯å¤±è´¥ï¼
温馨提示:答案为网友推荐,仅供参考
第1个回答 2017-04-03
推荐使用PDO连接。mysqli是扩展连接