Prestashop magic quotes fix

This one requires some PHP knowledge. This is a core hack.

Today i installed Prestashop and i’ve got a lot of trouble with lots of backslashes in an otherwise valid SQL query. Somehow i’ve managed to get thru it by altering the installation code and removing the addslashes functions. I know it’s not the best way, but it worked for me.

It’s okay to do this with the installation script, but Prestashop has many files, including smarty templates which may be a tremendous task to modify, and it’s not recommended.

I recommend to insert the code shown below into the index.php file found in your install folder too.

So, i checked something on my server, namlely the magic_quotes_runtime directive in PHP.ini. It was enabled (set to ‘on’). As i can see, both Prestashop and Smarty are having problems with this setting. What i did, was to change this setting to ‘off’ and restart my apache server.

What if you don’t have access to the php.ini file? (Shared hosting, permissions, etc). Open the main index.php file in your Prestashop folder, and insert into the second line:


Save the file.

This one solves the problem with blank Front page and backslashes in different texts.

Open the php.ini file in your prestashop admin folder (That one you renamed after installation) and insert after the comments, before the line define(‘PS_ADMIN_DIR’, getcwd()); the following:


Save the file.

This one solves the problem with payment module parse errors in the Back office page.

This trick worked for me.

Warning! If you are using a free shared hosting service, there is a high chance, that php runs in safe mode, or some functions are disabled. The ini_set function is often disabled on such kind of hosting services. In this latter case, you have to find another hosting provider.

2 thoughts on “Prestashop magic quotes fix

    • Hi,

      This article has been published back in 2008 (as it’s date shows).
      I think, that PS was then somewhere around 1.0x.

      I’m not sure if this applies for newer versions.

      The problem occurred on a weird server configuration, with Magic quotes turned on.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.