php - MySQLi Connection Issue -


i having trouble getting mysqli connect , respond properly. should relaying connection error time unable connect database, doesn't, when enter invalid details in attempt force connection error.

$emailaddress = $_post['emailaddress']; $password = $_post['password']; if ($emailaddress&&$password)     {         $db = new mysqli('loalhost','rot','','fitesshouse');         if($db->connect_errno > 0)           {             die('unable connect database [' . $db->connect_error . ']');         }     } 

edit: let me more clear. trying mysqli return connection error because connection fails. i'm not trying fix connection. when hit "submit" takes me blank page, means die statement not working.

fixed , have error:

notice: undefined index: emailaddress in /applications/xampp/xamppfiles/htdocs/fitnesshouse/login.php on line 5

this line of code should display error , stop script:

$db = new mysqli('loalhost','rot','','fitesshouse')     or die('unable connect database [' . $db->connect_error . ']'); 

you can use trigger_error instead of die:

$db = new mysqli('loalhost','rot','','fitesshouse'); if($db->connect_errno)     trigger_error('unable connect database [' . $db->connect_error . ']', e_user_error); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -