Solve problems with magic quotes in Joomla 3
Have you tried to install Joomla 3 and then having problems inserting images in articles and pages? One reason for such a mistake, is if magic quotes is set to On in the PHP settings. In this article I will try to explain the problem and how to solve it.
Description of the problem
The problem is that when you upload images and insert them into Joomla 3 articles (or pages), the code " is added to the HTML code of the images. Actually " is added every time you insert a HTML code containing the character “, which almost all HTML contains.
Reason for the problem
The reason why this happens is that the PHP setting magic quotes is turned On. It is a setting for PHP, that was originally developed to prevent beginners of entering bad code. So some characters (“, ‘, and NULL) was replaced with a . However this setting caused more problems for users of PHP, than it solved problems. So it is removed from the future PHP version 6.
So since there is no good reason to keep magic quotes turned on, you should turn it off.
Is magic quotes turned On at my Joomla installation?
If you want to see, if magic quotes is turned On or Off on your Joomla Installation, just login to the administration backend. Then choose “System” in the top menu and then “System information”. Then finally choose the tab “PHP setting” and you will find the status of magic quotes on the list that appears. If it is set to On, that might be the reason why you have the problem.
How to solve the problem with a PHP.INI file
One way to solve the problem is to add the following line to your PHP.INI file of your root folder and your administrator folder:
magic_quotes_gpc = Off
session.save_path = “/tmp”
If you don’t already have a PHP.INI file you can create it. Unfortunately, not all hosts allow to create your own PHP.INI file and if you try, it wont work. In this case you should solve the problems in a .HTACCESS file.
How to solve the problem with a .HTACCESS file
If you cannot solve the problem with a PHP.INI file, you can solve it in a .HTACCESS file. The .HTACCESS file is placed in your root folder. If there is no .HTACCESS file, you can either create a new one or rename the file HTACCESS.txt to .HTACCESS (Not .HTACCESS.txt). Then you can add the following line:
php_flag magic_quotes_gpc 0
This should work. Check if Magic quotes is turned off, by going to PHP settings in System -> System informations -> PHP settings in backend of your Joomla installation. At the list, Magic quotes should now be turned off.
I hope this solved your problem. If not you are welcome to write a comment about your problem.
When I put “php_flag magic_quotes_gpc off ” and “php_flag magic_quotes_sybase off” in .htaccess I gain a 500 Internal error and cant administrate my site, even too navigate from front-end. =(
I’m with the same issue
Hi Andre! Did the .HTACCESS file work before turning off margic quotes? Did you active URL rewrite and core SEO in Joomla?
Hello, i’m having the same problem, i’m having the error 500. How to fix? And what is this active core SEO URL rewrite and you quote?
THANK YOU! YOU SAVED ME! IT worked that last one with .htaccess !
You are welcome 🙂
I did some more to get it to work:
php_flag register_globals 0
php_flag magic_quotes_gpc 0
php_value session.gc_maxlifetime 3600
php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value max_input_vars 10000
php_value session.save_path /var/www/domain.com/sessions
Thank you for your solution 🙂
Wow, that’s a brilliant!
Thanks you very much ANDREAS, you’re saving my life. I have spending too much times for this stupid problem.
It solved now.
I’d like to go about the .htaccess solution. Where exactly on the page would I put it cause there is other stuff on the page….and I am new to all this.
Thanks
OMG Thank you so much! You are a genius! Even my host didn’t give me the right information. Now I can continue learning this Joomla! Thanks again!
I have magic_quote off in my php.ini file, If I run phpinfo it reports it is off, and the php.ini file being used is the one in my root folder, as it should be, But if go into Joomla admin, and view php info, it displays that it’s using the servers php.ini file and that magic_quotes are off. which is giving me issues.
It’s was joomla 2.5 with gantry upgraded to joomla 3.1,
I do have on the same server a install of joomla 3.1 with out the same problem.
any ideas?
Hi,
Tried the renaming of HTACCESS.txt to .HTACCESS and then changed the content so it only said:
php_flag magic_quotes_gpc 0
But it still is enable. What could I be doing wrong?
Thanks
Best
Kim
Thanks a lot for very nice and helpful article. I have also spent too much time for this stupid problem.
Now its solved.
Thanks
When I put “php_flag magic_quotes_gpc off ” in .htaccess I gain a 500 Internal error and cant administrate my site, even too navigate from front-end. =( –
Thanks man u made my day 🙂 I m happy that this kind of people still exist 🙂 thanks again 🙂
Thanks!! HTACCESS formular worked. Your instructions are clear.
Hi Andreas, I have problem with magic quotes, I’ve created php.ini
magic_quotes_gpc = Off
session.save_path = “/tmp”
but still doesn’t work, and my host provider doesn’t allow me to put php_flag in .htaccess, what should I do ?
Hi Soleh!
So you are no able to change HTACCESS? That is very uncommon. It is usually only PHP.ini that is restricted from change.
In that case I would say that your host does not support Joomla 3, since the magic quotes problem is a part of Joomla 3. So if they don’t want to change your PHP.ini or give you access to HTACCESS – I would change host. Who is your host?
thank youuuuuuuuuuuuu a lotttttttttttttttttttt
PHP.INI file of your root folder (Goddady)
magic_quotes_gpc = Off
session.save_path = “/tmp”
Good solution for my
It still not working for me bro !!!! how can i solve it???? do you know the other ways to do it??
Hello All,
I am facing image upload problem in my website. In editor insert image button is not working at front-end.In back-end its working fine. Please provide me the solution.