Jump to content

Problems with quotes in string literals (text, labels, SQL queries, etc) - A solution that might work


Recommended Posts

This one requires some PHP knowledge.

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.

You can find this post on my site in the resources page too.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More