Nightmare of PHP programmer: include_once fails

For a moment it was looking like our project got haunted. Suddenly we started getting errors from the libraries being included twice, function exists and class exits kind of error. First few times it was written off as a “honest” mistake and fixed on spot, but it continued to happen again and again. Of course, it was only showing up on production sites, none of the test sites had this issue. Some digging in the code and pulling hairs out lead to the issue: include_once was failing us. Yes, it was doing include of the same file again! One little detail – that only happened when we used...
read more

PHP ftp_connect causing Segmentation Fault (core dumped)

Pretty strange issue and I had hard time to Google it up, so here you go, fellow PHP developers. PHP script which was doing ftp_connect was failing on some installations with Segmentation Fault (core dumped) message. After quite a bit of time wasted looking for answers why, I found that problem was with the FTP host name having trailing line break. Well, that host name was coming from config and technically only developers had access to it, so looks like we assumed that variable “safe” and were not doing standard checks on special characters. To make things worse that line break is hard to...
read more

Eclipse too slow and out of memory

Looks like Eclipse PDT was getting quite slow on me, it thinks sometimes 10-15 seconds when I switch between files or save one. My current project is not small one, but still… Looking around for a solutions I found quite easy tip at http://www.eclipsezone.com/eclipse/forums/t61618.html In short – I am now running eclipse.exe -vmargs -Xms256m -Xmx256m -XX:PermSize=64m -XX:MaxPermSize=64m and my Eclipse is way faster. Thanks for the tip, Riyad Kalla!
read more

SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘xxx.xxx.xxx.xxx’ (13)

One of the things I wish I had found in Google faster when trying to figure out why PHP script refuses to connect to remote MySQL server issuing an error SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'xxx.xxxx.xxx.xxx' (13) I am able to connect from local shell, so first thought was if something wrong with recent Zend Framework upgrade, but after a while I figured out that answer is very simple – SELinux was blocking remote connections from PHP scripts executed by Apache web server. The error code (13) at the end of error message means “permission denied”, so that’s...
read more

Joomla profiling log

I am using Joomla for the content management, and it looks like my site is getting slow, no, not just slow, it’s SLOW. Quick check in the MySQL database showed that there is no really big tables which could cause some delays if not indexed properly or getting locked. So, next step would be naturally looking into the PHP code itself trying to identify bottlenecks. First of all – copy everything to test site – I don’t really want to shut the site down or display some debug info to the visitors. My test site is actually a linux box which is pretty old one, so it probably will run...
read more

« Previous Entries