Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $dbhost = "server";
- $dbuser = "test_db";
- $dbpass = "test_db";
- $dbname = "test";
- $mysql_conn_string = "mysql:host=$dbhost;dbname=$dbname";
- try{
- $dbConnection = new PDO($mysql_conn_string, $dbuser, $dbpass);
- }
- catch(PDOException $ex) {
- echo($ex->getMessage());
- }
- echo(PDO::errorInfo());
- try {
- //connect as appropriate as above
- $stmt = $dbConnection->prepare('bogus sql');
- } catch(PDOException $ex) {
- echo "An Error occured!"; //user friendly message
- echo($ex->getMessage());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement