Friday, June 19, 2009

Eclipse can not debug PHP web page (session terminated)

When using Eclipse with PDT to debug PHP, it can successfully debug PHP script, but everytime when tring to debug PHP webpage, it will terminated quickly with information saying of "session terminated".

The reason is because there are 3 lines must be added in php.ini.

zend_extension_ts="C:\Program Files\PHP\ext\ZendDebugger.dll" (You need to search in your Eclipse folder to find out where the file exists and use the full path to it.)
zend_debugger.allow_hosts=127.0.0.1
zend_debugger.expose_remotely=always

After adding these 3 lines, restart Apache, then it works.

Monday, June 15, 2009

Fatal error: Call to undefined function mysql_connect()

Well, I've long time not used PHP, and now I am back.

I installed the newest Apache, the newest PHP, the newest Mysql, and everything is smooth. Seems the UIs are much better than 4 years ago. I took pretty caution to the PHP configuration, and choosed to install mysql support at beginning, so everything seems ok at first.

But I met issue soon. When I call mysql_connect, it immediately says:

Fatal error: Call to undefined function mysql_connect() ...

As I am experienced engineer, I don't worry about this, checked all website for this issue, but everyone just repeatedly saying: check your php.ini file to remove the semicolon before the line of extension=php_mysql.dll, or check your extension_dir setting to make sure it's correct, something like that, blah, blah, blah... I checked again at my php.ini setting, it's pretty correct, because when I install php I already choose to have mysql support installed, so everything already correctly setting for me. I tried many other ways, to copy php.ini file into windows folder, to copy php_mysql.dll into windows folder, and also tried windows system32 folder, and also checked the environment variable of PHPRC, the problem just still be there.

Finally I got the problem solved. Now let me tell you the truth, this IS the exactly quite important step, but the PHP installation program did not do it correctly.

Very simple, that is: to copy the file libmysql.dll from your PHP folder into Windows folder. Very simple, right? But that's it.

Now we know, there are 3 files related to mysql support in php:

1. libmysql.dll (this by default is in ext folder, you can leave it there)
2. php_mysql.dll (this be default is in your php folder, you need to manually copy it into windows folder)
3. php.ini (this by default is in your php folder, you can leave it there)

You made them in correct folder, you got it.

Search

Google