NYCPHP Meetup

NYPHP.org

[nycphp-talk] Fatal error when trying to connect to dbusingDB/MySQL

Peter Lehrer pl at eskimo.com
Tue Sep 16 18:02:39 EDT 2003


That works.
----- Original Message -----
From: "Analysis & Solutions" <danielc at analysisandsolutions.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Tuesday, September 16, 2003 12:37 PM
Subject: Re: [nycphp-talk] Fatal error when trying to connect to
dbusingDB/MySQL


> Hi Peter:
>
> > I got it to work by including PEAR.php.
>
> I had a feeling you were calling the DB class incorrectly (and you still
> are).  I didn't say anything about it in my last message because I didn't
> have an example at my finger tips to show you.  Now I do...
>
> All you need to to is include DB.php, set the DSN and then connect.  The
> database type used is determined by the DSN.
>
>     require_once('DB.php');
>     $DSN = 'DB_Type://DB_User:DB_Pass@DB_Protocol+DB_Host:DB_Port/DB_Db';
>     $Options['debug'] = 2;
>
>     $db = DB::connect($DSN, $Options);
>     if ( DB::isError($db) ) {
>         $killProcess('Having problems connecting to the database: '
>                 . $db->getMessage() );
>     }
>
> Enjoy,
>
> --Dan
>
> --
>      FREE scripts that make web and database programming easier
>            http://www.analysisandsolutions.com/software/
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7th Ave #4AJ, Brooklyn NY    v: 718-854-0335   f: 718-854-0409
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
>




More information about the talk mailing list