为什么我的php 写不入数据库里面 一直失败 下面是代码?
$con=newmysqli("localhost","root","","classdb");$con->set_charset('utf8');if($con->co...
$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->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 "插入失败";
} 展开
2个回答
展开全部
<?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 "插入失败";
}
?>
这样试试
追问
一样是失败!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询