Am trying to display mysqli_error in my php scrip put I keeping getting black page if the query fails but return response when successful both mysqli_error($conn) and mysqli_errno($conn) are just displaying black page if the query fails. Here is my database connection script
<?php
$ser = "test";
$user = "test";
$pass = "test";
$db="test";
$conn = mysqli_connect($ser, $user, $pass, $db);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
My Php Query
<?php
include 'conn.php';
if ($conn) {
$sql = "INSERT INTO tbl_users (userId, email, pass) VALUES ('$userId', '$email', '$pass')";
if (mysqli_query($conn, $sql)) {
echo json_encode(array(
"status" => "Ok",
"message" => "Success",
));
} else {
echo json_encode(array(
"status" => "Error",
"message" => mysqli_error($conn),
));
}
}
An able to get the success response if the query runs correctly but i get a blank page once an error occurs if i use ini_set('display_errors', 1); i get the full page error but i need just the mysqli_error or mysqli_errno.