# help with backtrace/debuging

- Thread: https://externals.io/message/16092
- Original archive: https://news-web.php.net/php.internals/16092
- Started by Greg Donald on 2005-04-26T14:31:03+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #16092 — Greg Donald — 2005-04-26T14:31:03+00:00

URL: https://externals.io/message/16092#16092

I was looking into using the Pecl PDO extension a couple of days ago. 
I got it installed but when I try to use it dies.  Here's the bug
report I filed:

http://pecl.php.net/bugs/bug.php?id=4217&edit=2

I rebuilt my mod_php with debugging but I still can't get a backtrace
using gdb.  Do I have to also rebuild my apache with debugging?

Thanks,

-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

---

## #16129 — Dan Scott — 2005-04-28T23:20:47+00:00

URL: https://externals.io/message/16092#16129

> 
> > […]
> 
> I rebuilt PDO and enabled debugging.  It's acting a bit different now
> with debugging and being outside of Apache:
> 
> > […]
> #!/usr/bin/php -q
> <?php
> 
> error_reporting( `E_ALL` );
> 
> $extensions = `get_loaded_extensions()`;
> 
> if( in_array( 'pdo', $extensions ) )
> {
>     echo 'pdo.so extension already loaded';
> }
> else
> {
>     if( dl('pdo.so') )
>     {
>         echo 'pdo.so extension loaded with `dl()`';
>     }
>     else
>     {
>         echo 'pdo.so extension failed to load with `dl()`';
>     }
> }
> 
> $dsn = 'mysql:dbname=test;host=localhost';
> $user = 'root';
> $password = 'passwd';
> 
> try {
>    $dbh = new PDO($dsn, $user, $password);
> } catch (PDOException $e) {
>    echo 'Connection failed: ' . $e->getMessage();
> }
> 
> ?>
> 
> > […]
> 
> Warning: Module 'PDO' already loaded in Unknown on line 0
> pdo.so extension failed to load with `dl()`Connection failed: could not
> find driver/var/tmp/portage/php-5.0.3-r1/work/php-5.0.3/Zend/zend_execute.c(3255)
> :  Freeing 0x08613A4C (16 bytes), script=./pdo.php
> === Total 1 memory leaks detected ===
> 
> > […]
> [PHP]
> 
> extension=pdo.so
> 
> ;;;;;;;;;;;
> ; WARNING ;
> ;;;;;;;;;;;
> ; This is the default settings file for new PHP installations.
> ; By default, PHP installs itself with a configuration suitable for
> ; development purposes, and *NOT* for production purposes.
> 
> --
> Greg Donald
> Zend Certified Engineer
> http://destiney.com/
> 

Oops, didn't mean to take this off-list...

So three things:
1. If you print the results of `get_loaded_extensions()`, you'll see
that pdo turns up as 'PDO', but you're looking for 'pdo' -- so the
result of your first if() is FALSE.
2. You then try loading pdo.so again, but it's already loaded by
php.ini, therefore you get the Warning and your own error message.
3. You plan on connecting to MySQL, but don't appear to have loaded
pdo_mysql.so anywhere. So you need to fix that.

Dan

---

## #16143 — Greg Donald — 2005-04-29T15:26:17+00:00

URL: https://externals.io/message/16092#16143 · In reply to: #16129

> So three things:
> 1. If you print the results of `get_loaded_extensions()`, you'll see
> that pdo turns up as 'PDO', but you're looking for 'pdo' -- so the
> result of your first if() is FALSE.

Yup.  Confusing that the base extension is PDO, but the drivers are
lowercase like pdo_mysql for example.  I see what's going on now.

> 2. You then try loading pdo.so again, but it's already loaded by
> php.ini, therefore you get the Warning and your own error message.

Yup.  :)

> 3. You plan on connecting to MySQL, but don't appear to have loaded
> pdo_mysql.so anywhere. So you need to fix that.

I didn't realize I had to build pdo_mysql.so seperately.  Thanks.  In
the manual where it says "The following drivers currently implement
the PDO interface:" made me thing I got them all when I built PDO.


Now that I got all that worked out MySQL refuses my dsn string:

Connection failed: SQLSTATE[HY000] [2003] Can't connect to MySQL
server on '127.0.0.1' (111)

I can connect using this user and password using the mysql command
line client with no problems.  I have other PHP scripts connecting
successfully with this user as well.  See any problems with this code?

$dsn = 'mysql:host=127.0.0.1;dbname=test';
$user = 'root';
$password = 'changeme';

try
{
   $dbh = new PDO( $dsn, $user, $password );
}
catch( PDOException $e )
{
   echo 'Connection failed: ' . $e->getMessage() . "\n";
}


My MySQL user works otherwise:

> mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.0.24

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Thanks,


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

---

## #16144 — Dan Scott — 2005-04-29T17:53:40+00:00

URL: https://externals.io/message/16092#16144 · In reply to: #16143

> 
> > […]
> 
> Yup.  Confusing that the base extension is PDO, but the drivers are
> lowercase like pdo_mysql for example.  I see what's going on now.

That is not entirely true; PDO_ODBC, for example, comes up as
"PDO_ODBC". Unfortunately I don't have mysql-devel installed so I
can't confirm your report for PDO_MYSQL.

> > […]
> 
> Yup.  :)
> 
> > […]
> 
> I didn't realize I had to build pdo_mysql.so seperately.  Thanks.  In
> the manual where it says "The following drivers currently implement
> the PDO interface:" made me thing I got them all when I built PDO.

The manual also says (in the install instructions):

 "Follow the same steps to install and enable the PDO drivers of your choice."

> Now that I got all that worked out MySQL refuses my dsn string:

Sorry, can't help you there...

Dan

---

## #16147 — Greg Donald — 2005-04-29T18:49:16+00:00

URL: https://externals.io/message/16092#16147 · In reply to: #16144

> 
> That is not entirely true; PDO_ODBC, for example, comes up as
> "PDO_ODBC". Unfortunately I don't have mysql-devel installed so I
> can't confirm your report for PDO_MYSQL.


> cat extensions.php 
#!/usr/bin/php
<?php

print_r( `get_loaded_extensions()` );
    
?>

> ./extensions.php   
Array
(
    [0] => xml
    [1] => standard
    [2] => SPL
    [3] => sockets
    [4] => SimpleXML
    [5] => session
    [6] => readline
    [7] => pspell
    [8] => pgsql
    [9] => pcre
    [10] => pcntl
    [11] => ncurses
    [12] => mysql
    [13] => mhash
    [14] => mcrypt
    [15] => mbstring
    [16] => imap
    [17] => iconv
    [18] => gettext
    [19] => gd
    [20] => ftp
    [21] => fam
    [22] => dom
    [23] => dba
    [24] => curl
    [25] => ctype
    [26] => bz2
    [27] => zlib
    [28] => openssl
    [29] => libxml
    [30] => PDO
    [31] => pdo_mysql
)



-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/
