-3

I am working on android app project and in this project, i need to connect my android app with PHP and MySQL everything is fine but I am getting an error in my user registration .php file error like this

Warning: mysqli_close() expects parameter 1 to be myself, null given in C:\xampp\htdocs\panel\UserRegistration.php on line 35

I have tried many things but the error is still there.

Here is what I have tried:

<?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';
}
}


?>
Gilles Gouaillardet
  • 8,193
  • 11
  • 24
  • 30

2 Answers2

0

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

You must do : mysqli_close($con); :)

Ben
  • 99
  • 1
  • 4
  • i have done this but still am getting the same error Warning: mysqli_close() expects parameter 1 to be myself, null given in C:\xampp\htdocs\panel\UserRegistration.php on line 35 – Muhammad Sajid Lakha Jan 01 '18 at 12:59
0

Pass Connection object in mysqli_close() function.

Like :

mysqli_close($con);