Results 1 to 2 of 2

Thread: [RESOLVED] Multiple PDO DB connections

  1. #1
    Join Date
    Jun 2009
    Chi town. IL68 ICAO code home airport, literally.

    resolved [RESOLVED] Multiple PDO DB connections

    Hello all. I am trying to connect to multiple databases but testing lines of code one at a time, but I dont get any of my messages to echo out onto the page. Now the question is, does my code fail? Or did i write it wrong? No log is created this time around so I am assuming its not failing (Last time I wrote this and tested, there would be an error log created, this time no error log)

    Anyone have any idea??

    //trys to connect to each database
    try {
    $db1 = new PDO('mysql:harcerze_******; host=**.***.***.***', '*********', '*********');
    } catch (PDOException $ex) {
    	if($db1 == false)
    		echo 'Connect Failed: ' .$ex->getMessage();
    			else {echo 'Connected to DB1';}
    For want of a nail...the horseshoe was lost. For want of a horseshoe, the steed was lost. For want of a steed...the message was not delivered. For want of an undelivered message.....the war was lost.

  2. #2
    Join Date
    Aug 2004
    Code in the catch{} block will only run if an exception occurs, so you'll never see the success message in there.
    PHP Code:
    try {
    $db1 = new PDO('mysql:harcerze_******; host=**.***.***.***''*********''*********');
    "<p>Debug: connected to DB1</p>\n";
    // continue doing whatever you want with $db1 . . .
    } catch (PDOException $ex) {
    $msg $ex->errorInfo;
    "<p>Sorry, there was an unrecoverable database error. Debug data has been logged.</p>");
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center