Mysqli_close()期望参数1为mysqli

时间:2018-01-01 12:52:28

标签: php android mysql database error-handling

我正在开发Android应用程序项目,在这个项目中,我需要连接我的Android应用程序与PHP和MySQL一切都很好,但我收到一个错误的用户注册.php文件错误像这样

  

警告:mysqli_close()期望参数1为我自己,给定null   在第35行的C:\ xampp \ htdocs \ panel \ UserRegistration.php

我尝试了很多东西,但错误仍然存​​在。

以下是我的尝试:

<?php
if($_SERVER['REQUEST_METHOD']=='POST'){

include 'DatabaseConfig.php';

$con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);

$id_name = $_POST['id'];
$U_name = $_POST['username'];
$password = $_POST['password'];
$cnic = $_POST['cnic'];
$email = $_POST['email'];
$phone = $_POST['phone'];


$CheckSQL = "SELECT * FROM Users WHERE email='$email'";

$check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));

if(isset($check)){

echo 'Email Already Exist';

}
else{ 
$Sql_Query = "INSERT INTO Users (id,username,email,password_cnic,phone) values ('$id','$U_name','$email','$password','$cnic','$phone')";

if(mysqli_query($con,$Sql_Query))
{
echo 'Registration Successfully';
}
}


?>

2 个答案:

答案 0 :(得分:0)

https://secure.php.net/manual/fr/mysqli.close.php

你必须这样做:mysqli_close($con);  :)

答案 1 :(得分:0)

在mysqli_close()函数中传递Connection对象。

喜欢:

"<?=\yii\helpers\Url::to(['phone/index'])?>"