# Problem reading exception stack (using 5b3)

- Thread: https://externals.io/message/6684
- Original archive: https://news-web.php.net/php.internals/6684
- Started by mfischer@gjat.josefine@Markus Fischer on 2003-12-23T01:04:42+00:00
- Messages: 2
- 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

---

## #6684 — mfischer@gjat.josefine@Markus Fischer — 2003-12-23T01:04:42+00:00

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

From my current tests I get the following stack:

[23-Dec-2003 01:55:10] PHP Fatal error:  Uncaught exception 'exception' with message 'Unable to connect to database; mysql_error = Unknown MySQL Server Host 'bla' (4)' in /home/mfischer/php/System.php:12
Stack trace:
#0 /home/mfischer/php/Database/MySQL.php(30): mysql->mysql_connect('bla', '', '')
#1 /home/mfischer/htdocs/php5/test.php(5): mysql->connect('hostname=bla')
#2 {main}
  thrown in /home/mfischer/php/System.php on line 12

    However, the code flow is as the following:

    1) /home/mfischer/htdocs/php5/test.php(5):

            $db->connect("hostname=bla");

       'connect' method of object '$db' is called; not of object
       '$mysql' (only the class is called mysql)
        
    2) /home/mfischer/php/Database/MySQL.php(30):

            $this->resource = System::mysql_connect($this->hostname, $this->username, $this->password);

       The static method 'mysql_connect' of the 'System' class is
       called (and not mysql->mysql_connect);

    3) /home/mfischer/php/System.php(12):

            throw new Exception("Unable to connect to database$mysql_error");


    So, for me it seems that
    a) the order of the stack is not right (0->1->2 should be 1->0->2)
    b) the called function on the stack doesn't reassemble the real
       names. In #1 it should be $db->connect and in #0 it should be
       System::mysql_connect;


    Any ideas about this?

        - Markus

---

## #6711 — mfischer@gjat.josefine@Markus Fischer — 2003-12-23T23:05:35+00:00

URL: https://externals.io/message/6684#6711 · In reply to: #6684

Maybe some more information about how my code files are layed out
    may be helpful.

    /home/mfischer/htdocs/php5/test.php

        This is my test script which is executed via apache.
        It includes the file 'Database/MySQL.php'.

    /home/mfischer/php/Database/MySQL.php

        Includes the files 'Database/DatabaseInterfaces.php' and
        'System.php'.

    /home/mfischer/php/Database/DatabaseInterfaces.php

        Provides 'interface DatabaseInterface' and 'interface
        DatabaseResultInterface'.

    /home/mfischer/php/System.php

        Contains the class 'System' which only has static methods which
        wrap 1:1 with PHP (native) functions but providing Exceptions in
        case of errors.


    So, my code flow until the exception is thrown is:

        test.php(5) calls $db->connect()
        Database/MySQL.php(30) calls System::mysql_connect()
        System.php(12) throws the Exception

    However, the stacktrace reported from PHP reads:
[23-Dec-2003 01:55:10] PHP Fatal error:  Uncaught exception 'exception' with message 'Unable to connect to database; mysql_error = Unknown MySQL Server Host 'bla' (4)' in /home/mfischer/php/System.php:12
Stack trace:
#0 /home/mfischer/php/Database/MySQL.php(30): mysql->mysql_connect('bla', '', '')
#1 /home/mfischer/htdocs/php5/test.php(5): mysql->connect('hostname=bla')
#2 {main}
  thrown in /home/mfischer/php/System.php on line 12


    My problem is (in order of priority):

    1) the order in the trace is not correct
    2) the called methods do not match my code

    regards,

        - Markus
