Folks,
I see tutorials teach something like this:
[code]
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
if(!$conn = mysqli_connect(“localhost”,”root”,””,”buzzoff”))
{
die(‘Something went wrong. Please try again later!’);
}
$stmt = mysqli_stmt_init($conn);
$sql_count = “SELECT COUNT(id) FROM domains WHERE domain = ? OR domain_email = ?”;
if(!mysqli_stmt_prepare($stmt,$sql_count))
{
$_SESSION[‘error_report’] = __LINE__ .”n”;
$_SESSION[‘error_report’] = ‘Mysqli Error: ‘ .mysqli_error($conn) .”n”;
$_SESSION[‘error_report’] = ‘Mysqli Error Number: ‘ .mysqli_errno($conn) .”n”;
Note the:
1st Code
[code]
mysqli_error() //empty inside brackets.
mysqli_errno() //empty inside brackets.
But should not it be something like this instead ?
2nd Code
[code]
mysqli_error($conn) //NOT empty inside brackets.
mysqli_errno($conn) //NOT empty inside brackets.
Here is the context …
3rd Code
[code]
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
if(!$conn = mysqli_connect(“localhost”,”root”,””,”buzzoff”))
{
die(‘Something went wrong. Please try again later!’);
}
$stmt = mysqli_stmt_init($conn);
$sql_count = “SELECT COUNT(id) FROM domains WHERE domain = ? OR domain_email = ?”;
if(!mysqli_stmt_prepare($stmt,$sql_count))
{
$_SESSION[‘error_report’] = __LINE__ .”n”;
$_SESSION[‘error_report’] = ‘Mysqli Error: ‘ .mysqli_error($conn) .”n”;
$_SESSION[‘error_report’] = ‘Mysqli Error Number: ‘ .mysqli_errno($conn) .”n”;
Which code should I stick to ?
The 3rd one showed error the other night but tonight no errors.
Strange.
Hence, enquiring.