Code Comments
Programming Forum and web based access to our favorite programming groups.Bob Leitner wrote:
> All seemed fine until my script had to access the db - I get a DB
> Error: connect failed.
What does your DSN look like? If the regular mysql_* functions work,
then DB should work. I would think that it has to do with an error in
your code or DSN string.
Paste some code.
> If nothing else, how do I get more
> information regarding the error? Like did it fail because of credentials,
or
> whatever?
$db = DB::connect($dsn);
if (DB::isError($db)) {
die($db->getMessage());
}
Is that what you're doing?
Aaron
Post Follow-up to this messageHi Aaron,
in one file I define the DSN, which is using the same variables as I use to
connect using php functions, which is:
$dsn = "mysql://$dbusername:$dbuserpassword@$dbhost/$default_dbname";
in another file I include the above file, have the require_once 'DB.php';,
and the connection call is:
$db = DB::connect($dsn);
if (DB::isError($db)) {
die ($db->getMessage());
}
$sql1 = "SELECT options FROM elements WHERE name = '$element_name'";
$result1 = $db->query($sql1);
if (DB::isError($result1)) {
die ($result1->getMessage());
}*/
$result1 = mysql_query($sql1);
if (!$result1) error_message(sql_error());
//$data1 = $result1->fetchRow(DB_FETCHMODE_ASSOC);
fairly straight forward, and it worked fine when everything was set up on my
local laptop. I thought it might have something to do with PEAR because I
can connect using the same variables with php funcitons.
Anything you see wrong? Or any other thoughts?
thanx,
bob
"Aaron Wormus" <aaron@wormus.com> wrote in message
news:412E14D0.1010902@wormus.com...
> Bob Leitner wrote:
>
>
> What does your DSN look like? If the regular mysql_* functions work,
> then DB should work. I would think that it has to do with an error in
> your code or DSN string.
>
> Paste some code.
>
credentials, or
>
> $db = DB::connect($dsn);
> if (DB::isError($db)) {
> die($db->getMessage());
> }
>
> Is that what you're doing?
>
> Aaron
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.