Currently Browsing: PHP

Magento: “Fatal error: Uncaught exception” erorr when trying to access Magento Connect manager

That’s a known bug and is present in Magento since version 1.1.2 and still isn’t fixed. The solution is quite easy and takes less than 5 minutes :) Simply edit the following file using cpanel’s file manager: app/code/core/Mage/Core/Model/App.php in it around line 558, you should find...

Magento error — Notice: Undefined index: 0 in app/code/core/Mage/Core/Model/Mysql4/Config.php on line 92

This will most likely occur when migrating Magento from one host to another. The fix, while not so obvious and easy t find turned out to be quite easy ;)  During the installation, Magento sets two IDs to 0 in its database. However, when importing the database dump to your new host, MySQL doesn’t...

Find the full path to a program

Quite often, when you are installing an application on your host, it asks for the full path to a program. Galleries for example, will need the full path to the convert executable of ImageMagick, some e-commerce scripts need the full path to the curl binary, etc. Of course you can always contact your...

PHP function test

Most hosting companies today, which offer PHP hosting tend to disable certain PHP functions mostly for security reasons. Contacting support to check if a function is available or not can sometimes be really tough. To save you all this trouble, here is a short script, which will tell you if a function...

Add form fields dynamically with JavaScript

If you have ever used GMail you have most probably already seen this at the attachments page, where you can dynamically add attachment slots without even refreshing the page. You can achieve this effect easily and I will just show you how to do it. For the purpose of course, we will use JavaScript, so...

How to Get the Current Page URL

In some cases, you might want to get the current URL of the script that is being executed. I haven’t yet found a convenient one-line function that is built-in into PHP and thus I’ve wrote the following function to do it: /** * Returns the current URL of the script. * Usage: $url = cur_page_url(); ...

Installing eAccelerator on Ubuntu

If you have a small server for your own use (such as your personal page) or have a busy server servicing a lot of php requests you might find it a good idea to install some goodies in order to optimize the performance of your machine. A really good start might be installing the eAccelerator. The eAccelerator...

PHP Checkbox values

This one puzzled me for some time… may be I’ve overlooked the php documentation, but I couldn’t find how to make use of the standard checkbox and return the selected values as an array from a simple form. In the end, it turned to be easy. Consider that we have the following form: <html> <form...

How to remove the last character of a string

Remove the last character in PHP In Perl, the chop function removes the last character in a string, but in PHP it removes trailing white spaces only. To get the same functionality into PHP you can use the substr_replace() function. For example: $string = substr_replace($string,”",-1); will remove...