Re: confirming installation
| From: | Bob Leitner | Date: | Thu, 26 Aug 2004 20:32:59 +0000 |
| Subject: | Re: confirming installation | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14319@lists.php.net to get a copy of this message | ||
Hi 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:
>
> > 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