RE: [PEAR] RE: [PHP] Re: [PEAR] Trying to install Log
| From: | Joseph Blythe | Date: | Mon, 16 Jun 2003 03:40:56 +0000 |
| Subject: | RE: [PEAR] RE: [PHP] Re: [PEAR] Trying to install Log | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5978@lists.php.net to get a copy of this message | ||
Stan,
hmm try this dsn instead:
$dsn = $server . "://" . $user . ":" . $password . "@" . $host .
"/" .
$database;
make sure $server is a valid database type eg: mysql
Regards,
Joseph
-----Original Message-----
From: Stan Lemon [mailto:insyder@myrealbox.com]
Sent: Monday, 16 June 2003 12:54 PM
To: Joseph Blythe; pear-general@lists.php.net
Subject: Re: [PEAR] RE: [PHP] Re: [PEAR] Trying to install Log
Joseph,
Thanks for the code, let me tell you what error it produced for me:
DB Error: no database selected
I checked and made sure the db existed, the user I had, had permission,
and that the password was correct. I'm clueless. Any ideas?
I did do the selection of the database correctly didn't I?
The code you sent me is at: http://beta.insyderhomielc.com/dbtest2.php
(At the top I printed out the database name to make sure I had it set)
Thanks,
- Stan
Joseph Blythe wrote:
>Stan try the following code, I have a feeling that the db connection is
>failing:
>
><?php
>ini_set("include_path","/usr/share/pear/");
>require_once("DB.php");
>include("functions/connect.mn.php");
>
>$dsn = $server://$user:$password@$host/$database
>
>$db = DB::connect($dsn);
>
>if (DB::isError($db)) {
> die ($db->getMessage());
>}
>
>$sql = "SELECT * FROM ps_config WHERE site=1";
>
>if ( DB::isError( $result = $db->query( $sql ) ) ) {
> die ($result->getMessage());
>} else {
> $row = $result->fetchRow(DB_FETCHMODE_OBJECT);
>}
>?>
>
>Hope this helps should or at least produce a better error :)
>
>Regards,
>
>
>Joseph
>
>-----Original Message-----
>From: Stan Lemon [mailto:insyder@myrealbox.com]
>Sent: Monday, 16 June 2003 12:23 PM
>To: php-general@lists.php.net
>Subject: [PHP] Re: [PEAR] Trying to install Log
>
>
>I'm using the mysql driver, so $server = "mysql"; I am also very
>confident that mysql support is provided correctly through php because
>up until recently I've used mysql_....() functions and never experienced
>a problem.
>
>I have no problem connecting, it's just the query() function doesn't
>want to go, it keeps telling me that no function exists.
>
>I tried the code you wrote and it didn't produce any errors.
>
>The following code is available at:
>http://beta.insyderhomielc.com/dbtest.php
>
><.?php
>
>// Set the include path for when I'm working with PEAR
>ini_set("include_path","/usr/share/pear/");
>// Grab DB for me
>include("/usr/share/pear/DB.php");
>
>// My connection info that I use everywhere is in here
>include("functions/connect.mn.php");
>
>// Now connect me
>$db = DB::connect("$server://$user:$password@$host/$database");
>
>// Query to the db
>$query = "SELECT * FROM ps_config WHERE site=1";
>$result = $db->query($query) or die("I could not connect to the PageSite
>configuration table in the SQL database.");
>
>// Store the results in an associative array
>$config = $result->fetchRow(DB_FETCHMODE_ASSOC);
>
>?.>
>
>If you need to see my php configuration go to:
>http://beta.insyderhomielc.com/php.php
>
>I'll be honest, I am clueless. I don't have a single problem on my
>harddrive.
>
>This is consistent though, I had the same problem on another CPanel
>based server.
>
>- Stan
>
>
>
>