MyBB Community Forums

Full Version: Every apostrophe adds a \
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
everytime I add a apostrophe on my forum it turns into a '\

It's messing all my code up

does anyone have a solution?
Ask your host to disable magic quotes.
contacted them asking them that hope it works.
If the host can't turn off magic quotes, heres code I use to clean up the magic quote additions:

// Strip slashes from GET, POST and COOKIE arrays to take care of magic quotes
// strips slashes to a multi dimensional array, by reference
function stripslashes_arrays(&$array) 
{
if ( is_array($array) )
{
	$keys = array_keys($array);
	foreach ( $keys as $key ) 
	{
		if ( is_array($array[$key]) ) 
		{
			stripslashes_arrays($array[$key]);	
		}
		else 
		{
			$array[$key] = stripslashes($array[$key]);
		}
	}
}
}
  
// --- Handle input var escapes
// magic_quotes_runtime make sure it's turned off
set_magic_quotes_runtime(0);
// All escapes are handled from code...
// So rather, strip slashes if magic quotes is enabled
if( get_magic_quotes_gpc() ) 
{
	stripslashes_arrays($_GET);
	stripslashes_arrays($_POST);
	stripslashes_arrays($_COOKIE);
}
// End magic quote clean up script
my host said...

You can have your own php.ini file within your website to disable magic quotes.
-----------------------------------------------------------------------


G33K where do I put that code you added?
do I make a notepad and put all your code in and save as php.ini and then upload to the root?
(2010-12-01, 12:39 PM)activebf Wrote: [ -> ]my host said...

You can have your own php.ini file within your website to disable magic quotes.
-----------------------------------------------------------------------


G33K where do I put that code you added?
do I make a notepad and put all your code in and save as php.ini and then upload to the root?

The above code is to be used at the top of your code before anything else is ran.

However, since you can use php.ini then you don't use the above code. Put the following lines in your php.ini file:

magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off

Ask your host where they expect the php.ini file to be to be recognized.