Page 1 of 1

Eclipse debugging and mysql connections

Posted: Sat Jun 06, 2009 7:14 pm
by thinsoldier
Anyone have any idea why I can connect to and browse my mysql database using Eclipse's Data Source Explorer but when I try to debug a page php says it can't connect to mysql.

My debug output is the typical:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /Applications/XAMPP/xamppfiles/htdocs/_experiment_islandslimited/includes/commonConfig.php on line 60
Could not connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

But if I load that file in the browser via localhost it all works fine. I've been trying to debug with eclipse for over 6 months now and have had zero success with any code that relies on a mysql database. :cry:

Also I just got xdebug installed into my php but I can't get it to show up as a debugger option in eclipse (Zend Studio for Eclipse actually).

Re: Eclipse debugging and mysql connections

Posted: Sat Jun 06, 2009 7:55 pm
by thinsoldier
Suddenly, some success....

First I had to enable xdebug to be a selectable option in the eclipse preferences.
http://www.maxhorvath.com/2008/08/how-t ... lipse.html

Once I was able to actually select xdebug as an option, I was then able to create a new php server setting and php executable setting in eclipses preferences.
I set those all up to point to my xampp files php binary and php.ini

Once I did that I was able to debug a file with "debug as > PHP script" and step through everything including database driven loops. :)

However Debug As PHP web page seems to be acting up. The first time I used it, it just loaded the local url and rendered the final html in the Browser Output panel. The next time I used it I got a progress bar down in the lower right that never ever stops and the error "web launch already running". No idea what that's about.

Also I noticed on an IBM article that when they were configuring the zend debugger they added some settings to the php.ini beyond just enabling the debugger. But when it came to configuring xdebug they didn't give any additional settings.
In another article I saw similar settings for xdebug so I added those to my php.ini

Code: Select all

xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
http://unitstep.net/blog/2009/01/26/get ... debug-php/

Re: Eclipse debugging and mysql connections

Posted: Sat Jun 06, 2009 10:16 pm
by Doug G
You need to setup server debugging if you want to use the zend debugger through your web server. Otherwise the zend debugger in Eclipse PDT will use a built-in php engine, bypassing your web server.

Doing this is fairly easy, you download the appropriate zend server debugger program, you can find it somewhere on the zend pdt site, then you add a zend section to your php.ini (instructions included in a readme in the download), and finally you copy a dummy.php file into your web root.

Then from within eclipse you choose to debug on server and setup a debug profile and if you did things right you're stepping through your code.

I did this using the Eclipse PDT all-in-one download which included the zend debugger.