how to clear the following error
Warning: mysqli_error() expects exactly 1 parameter, 0 given
my code as follow
session_start();
$conn = mysqli_connect("localhost","root","","mahi") or die(mysqli_error());
$user_check =$_SESSION['user_id'];
//echo $_SESSION['user_id']; exit();
$conn = mysqli_connect("localhost","root","","register") or die(mysqli_error());
$results = mysqli_query($conn," SELECT name,age,mobilno,email FROM register WHERE id='".$_SESSION['user_id']."' ") or die('Error: '.mysqli_error());
//echo '<pre>'; print_r($result); exit();
$row =mysqli_fetch_row($results);
{
echo 'welcome'.$row['name'].'<br>';
echo 'your age is'.$row['age'].'<br>';
echo 'your mobile number is'.$row['mobilno'].'<br>';
echo 'your email is'.$row['email'].'<br>';
}
You must enter as parameter your connection link:
$conn = mysqli_connect("localhost","root","","mahi") or die(mysqli_error($conn));
You are missing the parameter - for procedural style it`s like this (refer to manual):
mysqli_error($conn)
mysqli_error()
requires your $conn
as parameter. It literally states in the error that it requires 1 parameter instead of the 0 you provided. So add mysqli_error($conn)
on both lines you use it.
You have to pass your connection variable inside your mysqli_error() function as it requires parameter.
mysqli_error($conn);
Also you have two connection strings on page and you assigned it to same variable $conn.so the last connection will overwrite the first one.try using two different variables.