mysql_connect will give me an error report. mysqli_connect gives me a blank page.
This does gives me an error report
$mysql_con = mysql_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_table);
if(!$mysql_con) {
die("Some error occurred during connection " . mysql_error($mysql_con));
}
This does not give me an error report:
$mysql_con = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_table);
if(!$mysql_con) {
die("Some error occurred during connection " . mysqli_error($mysql_con));
}
Nor does this
$mysql_con = mysql_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_table)
or die("Some error occurred during connection " . mysqli_error($mysql_con));
I have tried both and same thing: Blank white page
error_reporting(E_ALL);
error_reporting(-1);
When I say blank white page I mean nothing at all is displayed. None of my HTML or css or anything. It completely stops the script. mysql_connect
seems to function and loads the page fully even with an error.
When do do this locally (localhost), mysqli_connect
works just fine and gives an error when needed. The DB im connecting to is the same one, the only difference is in the above script Im letting it execute from a remote server to access my db on my local system. Even if it cant access it for whatever reason, why would it give me a blank screen?
Edit
Its magically working and giving me errors properly now using the following code.
$con = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
if(mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}