How to fix Fooman speedster in Magento Fatal error: Uncaught exception ‘JSMin_UnterminatedStringException’

After installing Fooman Speedster on Magento version, got several javascript errors. Both admin menu and front-end menu stopped to work.

I got the following error:

Fatal error: Uncaught exception 'JSMin_UnterminatedStringException' with message 'Unterminated String: '\'\\*\\+/=\\?\\^_`\\{\\|}~-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,})/i.test(v)'

How have I fixed it?
First, I opened the following url for which I was getting this error, copied from Firefox’s Firebug extension.,/js/prototype/deprecation.js,/js/prototype/validation.js,/js/scriptaculous/builder.js,/js/scriptaculous/effects.js,/js/scriptaculous/dragdrop.js,/js/scriptaculous/controls.js,/js/scriptaculous/slider.js,/js/varien/js.js,/js/varien/form.js,/js/varien/menu.js,/js/mage/translate.js,/js/mage/cookies.js,/js/sb/src/js/lib/yui-utilities.js

Obviously you should see the same error till now.

Now, I removed one js file and requested the above URL, how? say you would want to remove validation.js, then URL should be,/js/prototype/deprecation.js,/js/scriptaculous/builder.js,/js/scriptaculous/effects.js,/js/scriptaculous/dragdrop.js,/js/scriptaculous/controls.js,/js/scriptaculous/slider.js,/js/varien/js.js,/js/varien/form.js,/js/varien/menu.js,/js/mage/translate.js,/js/mage/cookies.js,/js/sb/src/js/lib/yui-utilities.js

Notice I have removed /js/prototype/validation.js,

Ok, now there is no more error. So, the error is somewhere in the validation.js. In Magento, open the /js/prototype/validation.js and need to replace Line no 431

return Validation.get('IsEmpty').test(v) || /^[a-z0-9,!\#\$%&'\*\+/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%&'\*\+/=\?\^_`\{\|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})/i.test(v)


 return Validation.get('IsEmpty').test(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v)

Should work fine now.


How to edit default email templates in Magento?

To change default email template, we need to edit html files in app\locale\en_US\template\email

If you are using other languages than en_US then open corresponding folder to make changes.

You also need to edit few more files, in order to get rid of these type of things:

{{layout handle="sales_email_order_items" order=$order}} 

so, make changes of files in app\design\frontend\your_theme\default\template\email otherwise you would see default email template.

how to capture all fields and values of a form at once in php?

Sometime we may have many fields in a form. We can get all field names and corresponding values at once in php nicely and field names which can be used as variables later.

For eg, you would like to save into database then create a table and make all database filed names same as form’s field names.

CREATE TABLE `student` (
`first_name` INT NOT NULL ,
`last_name` INT NOT NULL ,
PRIMARY KEY ( `id` )

I have a form as given below:

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
First Name : <input type="text" name="first_name"><br />
Last Name : <input type="text" name="last_name"><br />
<input type="submit" name="submit" value="Submit" >

While you submit the form, capture all variables, values and create SQL query to save into database:

	foreach($_POST as $variable => $key){
		${$variable} = trim($key);
        $sql = "INSERT INTO `student` (`first_name` ,`last_name`)
       VALUES ( '".$first_name."', '".$last_name."');"

How to define dynamic variable in php?

If you need to define variable dynamically in php then this can be done easily.
Say, your variable name will be ‘dynamic_variable_name’

Generally we define php variable normally as $normal_variable; but in this case we would like to create dynamically.
Then we have to write something like following way:

$normal_variable = 'dynamic_variable_name';
${$normal_variable} = 'New dynamic variable created';
echo $dynamic_variable_name;
// prints New dynamic variable created.

To explain it better I am giving an instance which will be very helpful to develop PHP sites and reduce some hard work.

I have a form as given below:

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
First Name : <input type="text" name="first_name"><br />
Last Name : <input type="text" name="last_name"><br />
<input type="submit" name="submit" value="Submit" >

While you submit the form, capture all variables and values:

	foreach($_POST as $variable => $key){
		${$variable} = trim($key);
        echo $first_name . '  ' . $last_name;

How to import / recover magento categories and products from the old store?

Well, I was really looking for a good way to import categories in magento, we know we can export and then import products gracefully from our old store but not categories. So, what you need to do is, you need phpMyAdmin to export and import tables or similar tool, though I would recommend phpMyAdmin.

  1. Step 1: Select the old database from where you would like to recover categories and products and click on export, please check the attached image file, you need to Disable Foreign Key checks and Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT.

  2. Step 2: Now, select all tables prefix with catalog and eav
  3. Step 3: finally Save as file
  4. Step 4: Install a fresh magento version, I have tested with version, so I would recommend install the same version as the old one. Say, old magento store version was then install a fresh copy of the same version.
  5. Step 5: Now, select the fresh database in phpMyAdmin which you have just installed and import the same old SQL file which you had exported in Step 3

If you don’t see any errors then look at new magento store, hope you would see all the products and categories.

You might not see new categories at the frontend, login to admin panel and enable Use Flat Catalog Category / Product.

Don’t forget to use the old media directory and ReIndex Data (System -> Index Management) :)

This method will be helpful if you would like to recover categories and products from the old corrupted database. This sometime happens we can not fix the old database even if you use the old database and install fresh magento.

Let me know whether you have successfully recover the old database or not.

How to fix Mage registry key “XXXXXX” already exists?

I got the following error message in a magento store after upgrading from to Though I moved products and categories from old site. And this lead me to see the error in the report directory:

Mage registry key "_resource_singleton/customer/customer_address" already exists

To fix this quickly, first, I simply commented a line in app/Mage.php file, line No.192

public static function register($key, $value, $graceful = false)
        if (isset(self::$_registry[$key])) {
			if ($graceful) {
            //self::throwException('Mage registry key "'.$key.'" already exists');
        self::$_registry[$key] = $value;

Above trick will resolve the issue quickly. Though I would not recommend. So, I restored the file as it was before. Then I looked at eav_entity_type table. And noticed in entity_model field value is customer/customer_address where entity_type_code is customer_address. This value should be customer/address, changed it, wow, started to work perfectly again!

So, if you see the similar error and don’t know how to fix in database then commenting the mentioned line will definitely help.

Let me how you have fixed :)


Google AdWords showing wrong report

I was checking my adwords account and surprisingly discovered that there was even not a single impression but 1 click. Yes, no impressions but click

Check the following screenshot:
adwords-no-impression-but click

I tried to see after few days but still no change:

Already mailed to Google but now reply yet.

Got reply from Google

I understand that you are seeing a click but no corresponding impression
to have caused this. This can happen sometimes, but please be assure you
that an impression happened to
cause the click. The biggest reason for this is the way the Search Query
Report (or in this case, the ‘See Search Terms) works.

Note that with this report, we don’t report every impression that comes in
expansions. The number of impressions on these expansions either has to be
‘significant’, or have a click. With that, we don’t always start recording
impressions until the click happens – and even then we don’t always record
it. That report is less about data (impressions, CTR, etc) and more about
showing you expansions your keywords are showing on.

paypal-reputation check

How to check PayPal account reputation?

Sometime we feel insecure while we get money or send money to an unknown person using PayPal. You may check PayPal reputation quickly by the following method:

  1. Click on Request Money
    paypal-reputation check
  2. Now go to next step, don’t request money after this step
  3. You would see something like below:

You may check your own reputation after login to your own account, visit


How to install multiple OS without formatting/partitioning hard disk?

If you would like to use multiple operating systems on your machine then we know we can install in separate drive or same drive or better to say partitioning hard disk. But there is another way to do the job without messing up your hard disk partition. No need to worry about, it is so simple to install/uninstall more than one operating systems on your PC or laptop on the fly!

You need a software named VirtualBox, you will be happy to know that it is an open source software developed by Sun.

Presently, VirtualBox runs on Windows, Linux, Macintosh and OpenSolaris hosts and supports a large number of guest operating systems including but not limited to Windows (NT 4.0, 2000, XP, Server 2003, Vista, Windows 7), DOS/Windows 3.x, Linux (2.4 and 2.6), Solaris and OpenSolaris, and OpenBSD.

That means you can install this software on Windows, Linux, Mac and OpenSolaris and install other operating systems by this software, you may have Linux, now install this VirtualBox and you would be able to install Windows 7 easily without messing up your harddisk or partitioning or spending time to install OS. No need USB drive also to test OS like Ubuntu or SuseLinux etc, you may install Windows 7 also. Those who are interested to install Windows 7 on external hard disk they may try using this software. Windows OS generally can not be installed on external hard disk, though by changing some files XP can be installed on external hard disk or USB disk (tested). Although we may not install Windows 7 on external hard disk.

You have to create Virtual hard disk to install Guest OS, but this is also an easier task, follow all steps correctly using Wizards. You may also remove the Virtual hard disk easily :)

Take a look I am installing more than one operating systems Ubuntu and Debian O/S simultaneously, my machine runs on Windows Vista

From the screen shot hope you understand how you could save time and test as many OS as you would like to run.

Only thing which I did not like is the window size is 800×600, guest OS could not detect my monitor and Display size is smaller, running on 24Bit than 32Bit color quality.

So, install many operating systems and see what may be a good choice for you!

After Installing Ubuntu and Debian:

How to fix Paypal Pro in Magento version

If Paypal Pro is not working in Magento version 1.4 while you clicking on button then it means there is some javascript issues.



Add the following line of code

<action method="addJs"><script>lib/ccard.js</script></action> 

where we can see other javascript files.

Refresh browser cache and flush magento cache, should work perfectly.