I have found a PHP custom function for mysqli query functions, but my problem is, how can I show an error of the mysqli function?
Here is the sample php mysqli function:
function connect()
{
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS);
$db = mysqli_select_db($con, DB_NAME);
return $con;
}
Query Function:
function query($sql)
{
return mysqli_query(connect(),$sql);
}
Fetch Assoc Function:
function fetchAssoc($sql)
{
return mysqli_fetch_assoc($sql);
}
And here is how it was called or used:
$sql_select = query("SELECT * FROM table_name");
$sql_result = fetchAssoc($sql_select);
$tbl_id = $sql_result['id'];
How can I show here if the SQL query is correct or have query error like incorrect field name or table does not exist?