Jump to content

Blank Page


JohnJ

Recommended Posts

I am attempting to set up a connection to a database via MySQLi. I recently entered invalid details to check whether or not the error reporting would work correctly; it didn't. It's simply showing me a blank page when I click "Sign In."

<?php


ini_set('display_errors', 1); error_reporting(~0);


$emailaddress = $_POST['emailaddress'];
$password = $_POST['password'];


if ($emailaddress&&$password)


{


$db = @new mysqli('loalhost','rot','','FitessHouse');


if($db->connect_errno) 


{
trigger_error('Unable to connect to database [' . $db->connect_error . ']', E_USER_ERROR);


}


}


?>

 

Link to comment
https://forums.phpfreaks.com/topic/277843-blank-page/
Share on other sites

You would only get an error if both of the conditions were true. You can add some debugging lines to see which conditions are true/false.

 

Try this and see what is returned:

 

echo "DEBUG: check if $emailaddress or $password are false<br>\n";
if ($emailaddress && $password)
{
    echo "DEBUG: $emailaddress and $password are not false<br>\n";
    $db = @new mysqli('loalhost','rot','','FitessHouse');
    if($db->connect_errno)
    {
        trigger_error('Unable to connect to database [' . $db->connect_error . ']', E_USER_ERROR);
    }
    else
    {
        echo "DEBUG: DB connection completed<br>\n";
    }
}
Link to comment
https://forums.phpfreaks.com/topic/277843-blank-page/#findComment-1429321
Share on other sites

Yes, that is the preferred way to do it. I typically create an application such that any page call will load a "bootstrap" file which will perform any common tasks. I would still have separate files for DB connection and other tasks, and then include those in the boostrap file.

Link to comment
https://forums.phpfreaks.com/topic/277843-blank-page/#findComment-1429326
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.