PHP Register Long Arrays HTTP_POST_VARS

I have been in the process of moving my websites from a dedicated machine running Gentoo Linux to a VPS (Virtual Private Server) running CentOS 5. One of the ecommerce websites uses an old install of osCommerce which expects register globals and register_long_arrays on, otherwise things won’t work very well.

While testing the site out on the new server, I couldn’t work out why some of the form posts were working and some weren’t. For example, on some pages I could add items to the shopping cart but on others I couldn’t. I also couldn’t click the form button to proceed to th checkout or update my basket: whenever I tried it kept showing me the same basket page again.

Categories PHP

Replacing relative URLs with absolute URLs in PHP

I’ve finally set up an RSS feed for this site and one of the things I needed to sort out was the use of URLs and image tags. All the anchor tags in this site are relative, and so are all the image sources. This isn’t going to work in an RSS feed because it would mean none of the links would work, and the images would all be broken. Fortunately this is easy to fix with the use of PHP’s string replacement functions.

Categories PHP

PHP Magic Constants

There are several PHP "magic constants" (or "magical contants") which can be useful for a variety of reasons. These magic constants aren’t actually constants at all, but effectively behave like them, although the values change depending on the context.

Categories PHP

MySQL Backups with a Command Line PHP Script

I run a number of web servers with PHP and MySQL and have a PHP command line script that runs on a daily basis to back up MySQL databases using the mysqldump command. It would be possible to do this using a simple bash script as well, and I know I used to use a bash script in the past but for some reason switched it to PHP at some stage.

Triggering errors with PHP

It is possible to trigger an error in PHP. This can be useful for debugging purposes, or if there is some condition which occurs in your PHP script which requires a PHP notice, warning or full error which causes the script to halt execution, and which would not be generated by PHP itself.

Categories PHP