Yesideez Posted April 24 Share Posted April 24 (edited) I have the following code and yesterday this was working and now I get nothing sent to my browser... <?php ini_set('display_errors','1'); //only during development ini_set('display_startup_errors','1'); //only during development error_reporting(E_ALL); //only during development $options=[ PDO::ATTR_EMULATE_PREPARES => false, // turn off emulation mode for "real" prepared statements PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, //turn on errors in the form of exceptions PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, //make the default fetch be an associative array ]; try { $pdo=new PDO("mysql:host=localhost;dbname=polthouse",'root','',$options); } catch (PDOException $e) { die('Connection failed: ',$e->getMessage()); } phpinfo(); ?> Edited April 24 by Yesideez Quote Link to comment https://forums.phpfreaks.com/topic/320107-connection-problems-and-no-error-messages-output/ Share on other sites More sharing options...
Solution Yesideez Posted April 24 Author Solution Share Posted April 24 (edited) FIXED! Somehow my try...catch section, the die() statement I've passed it two parameters as the . to concatenate strings turned into a comma. No idea how that happened but I've changed it to a . and it's all now working perfectly. Although I have no error message appear telling me there was a problem with it. Edited April 24 by Yesideez Quote Link to comment https://forums.phpfreaks.com/topic/320107-connection-problems-and-no-error-messages-output/#findComment-1622374 Share on other sites More sharing options...
dodgeitorelse3 Posted April 24 Share Posted April 24 (edited) already solved while I was typing lol Edited April 24 by dodgeitorelse3 Quote Link to comment https://forums.phpfreaks.com/topic/320107-connection-problems-and-no-error-messages-output/#findComment-1622376 Share on other sites More sharing options...
mac_gyver Posted April 24 Share Posted April 24 this is a parse/syntax error. to get php to report and display parse/syntax errors, you must have the php error related settings in the php.ini on your system, so that they are in effect before your php script is parsed, tokenized, and executed. error_reporting should ALWAYS be set to E_ALL. you cannot successfully set display_startup_errors in your code because php has already started by the time your code is running. during development, yes, you should have display_errors set to ON (or 1, e.g. a true value.) when running code on a live/public server, you should have display_errors set to OFF (or 0, e.g. a false value) and log_errors should be set to ON. the only database exceptions you should catch and handle in your code are for user recoverable errors, such as when inserting/updating duplicate or out of range user submitted data values. in these cases, the catch logic should test the error number and setup a message for the user letting them know what was wrong with the data that they submitted. for all other error numbers, just rethrow the exception and let php handle it. for all other query types and all other database statements that can fail, do nothing in your code and let php handle any database exception. when you let php catch and handle the database exception, php will 'automatically' display or log (using the php error related settings) the actual error information for you via an uncaught exception error. Quote Link to comment https://forums.phpfreaks.com/topic/320107-connection-problems-and-no-error-messages-output/#findComment-1622377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.