public function addemail(){
$email_name=$_POST['name'];
$email_email=$_POST['email']; $con=mysqli_connect("localhost","root","root","bottlelover")
or die('connect error'); mysqli_set_charset($con,"utf8"); $sql="SELECT * FROM email_list WHERE email_email = '$email_email'";
$result=mysqli_query($con,$sql)
or die('query1 error');
$row=mysqli_fetch_array($result);
if($row){
$this->assign("res",'邮箱已被使用,用户添加失败');
mysqli_close($con);
$this->display("Bottleloveradd");
}
else {
$sql="INSERT INTO email_list(email_name,email_email) VALUES ('$email_name','$email_email')";
$result=mysqli_query($con,$sql)
or die('query2 error');
$this->assign("res",'新用户添加成功');
mysqli_close($con);
$this->display("Bottleloveradd");
}
}
-------------------------------------------以上是问题代码-----------------------------------------------------IF条件一旦判断成功,就提示localhost连接已经中断,但是数据并不大,数据库bottlelover最多3行数据...
$email_name=$_POST['name'];
$email_email=$_POST['email']; $con=mysqli_connect("localhost","root","root","bottlelover")
or die('connect error'); mysqli_set_charset($con,"utf8"); $sql="SELECT * FROM email_list WHERE email_email = '$email_email'";
$result=mysqli_query($con,$sql)
or die('query1 error');
$row=mysqli_fetch_array($result);
if($row){
$this->assign("res",'邮箱已被使用,用户添加失败');
mysqli_close($con);
$this->display("Bottleloveradd");
}
else {
$sql="INSERT INTO email_list(email_name,email_email) VALUES ('$email_name','$email_email')";
$result=mysqli_query($con,$sql)
or die('query2 error');
$this->assign("res",'新用户添加成功');
mysqli_close($con);
$this->display("Bottleloveradd");
}
}
-------------------------------------------以上是问题代码-----------------------------------------------------IF条件一旦判断成功,就提示localhost连接已经中断,但是数据并不大,数据库bottlelover最多3行数据...
mysqli_close($con);
你的页面难道没有数据库查询出来的东西吗?你将数据连接关掉,怎么显示?
不对啊,我的这些带面并没有要求在页面显示什么,对于数据库的使用也只限于查询和插入,我在关闭数据库连接的时候已经不需要数据库了啊??还有,我现在在各种测试,发现问题在于mysqli_fetch_array()函数,当这个函数查到东西的时候,也就是说我的数据库中已经存在当前输入邮箱的时候,我的localhost就会断开连接,不管是DUMP也好,还是IF判断也好,只要使用到mysqli_fetch_array()函数查询到的结果,就会发生localhost断开连接,求大神解救!
大神又是你!
求解如何打开PHP错误提示,其实我已经发现是函数有问题,现在换回老版MYSQL系列函数就行了,但是我还是不懂为什么MYSQLI_fetch_array()会出错....
能给我QQ么,我简直觉得我们太有缘了
#这样写,报什么错误?
$result=mysqli_query($con,$sql);
if(!$result)
die("SQL: {$sql} <br>Error: " . mysqli_error() );
display_errors=On
error_reporting=E_ALL & ~NOTICE
重启apache
话说是在display_errors设置么?我的PHP.INI里面没有这个../.
; - error_reporting = E_ALL [Code Cleanliness, Security(?)]我找到这两句了,怎么改?要去掉分号么?
mysqli_close($con);这句写在循环里,当然会关闭。把它放在循环外面试试。
亲,虽然我不认为这个东西起作用,但是我还是测试过了,还是不行,而且我的是IF判断语句,不是WHILE