Categoriearchief: PHP

SQLSTATE[HY000] [2003] Can't connect to MySQL server

A while ago I was in a project which had separate CentOS web server and database servers. I had whitelisted the IP addresses we were using so the machines could reach each other, but all other connections were dropped. One would expect that to be enough, but my requests returned me ‘SQLSTATE[HY000] [2003] Can’t connect to MySQL server’. Apparently SE Linux didn’t want me to connect yet.

Verder lezen

Practical: creating a REST application with Silex

Okay, you’ve read LornaJane’s blogpost series on REST, you’ve attended the Techademy Silex/REST workshop to hear Stefan Koopmanschap talk about Silex and Joshua Thijssen about REST, seen the post of Dave Marshall on REST so what now?

Try and create a REST example application with Silex of course! This blogpost describes my steps creating this example application from front to back.

The order in which I’ve written down and done things is not pre-defined. There are multiple orders to achieve the same result. This is just the way I did it. Verder lezen

Getagged , ,

PHP SPL data structure: SplFixedArray

PHP 5.3 introduced some new data structures. The talk of Jurriën Stutterheim on PFCongres 2011 on SPL structures and their performance triggered me to have a closer look at the performance of these structures. I was kind of fooled by two comments on the page, so it was time to find out myself.

Verder lezen

Getagged , , , ,

Propel and the zero date issue

Today I was unpleasantly surprised by a change in behavior when upgrading Propel from version 1.5.4 to 1.6. I frequently use zero dates in MySQL (‘0000-00-00’) and these dates are affected by the upgrade. As it was deployment time I had to find a solution quickly. This post outlines what the problem is and what I did to solve it. Verder lezen

Getagged , ,

Starting a CLI script from PHP

For quite some time I’ve searched for a way to start a command line script from within a page in PHP without using the crontab. Basically I just wanted to start a script which does some processing in the background. The solution is pretty simple, but it took me some time to find it. Verder lezen

Getagged , , , , , , ,

PHP multidimensional array to plain text tree structure

Not for the first time I’ve searched for a way to visualize a multidimensional array in a tree view in my web browser without directly using echo or print. I wasn’t able to find a concrete solution for this previously. However, this time I was put on the right track by a post of Kevin van Zonneveld. Verder lezen

Getagged ,

PEAR install on Linux by a n00b for n00bs

Okay, I must admit: I’m a programmer and I know some commands. Because I want to use PEAR packages, I needed to install it. The installing command is quite easy to find, but I had a hard time determining the directory structure. Some searching on the internet and an IRC conversation (EFNet #pear, thanks davidc_!) later I was able to install PEAR in a quite reasonable directory structure. Verder lezen

Getagged , , ,

Developing using WampServer 2: additions

WampServer 2.0 is a nice tool to help you develop a new site on your local computer. However, you’ll probably need more packages/libraries than those included with WampServer. This post is about installing extra common features which are mostly present at hosting servers, but not (directly) on WampServer.

Verder lezen

Getagged , , ,

FPDF error: Unable to find xref table

Today I faced a problem with FPDF and FPDI when trying to concatenate some PDF files. The only output I got was ‘FPDF error: Unable to find xref table.’ When I did a search on this error message, I wasn’t able to extract the answer from it. After some searching, the problem was located.

Verder lezen

Getagged , ,

Working IPv6 regular expression

Multiple times I’ve been searching (too long) for a working IPv6 regular expression. There’s a lot of crap out of there which doesn’t take into account certain cases. Of course you only get to know which one works best if you test them all. I’ve tried A LOT and finally found the right one

Verder lezen

Getagged , ,