Jump to content

Preg_replace help - Replace ' " \ and / ?


mat3000000

Recommended Posts

I have no experience with the preg_ function, so could you show me how I would amend this:

 

$q = preg_replace("/[????]/","",$str);

 

Please could you explain what you are putting in there, or give me a link to a site which takes you through the syntax.

Thanks in advance

  • 2 weeks later...

Just a quick question to add to this...

 

I was using this along with the mysql_escape_string() function. Is this necessary because surely mysql injection can not occur without any of those characters???

:D

 

yes its necessary when you insert data into your sql table. If you deals with forms & you should escape the string.

:-* :-*

The your server is probably configured with magic_quotes_gpc() set to ON in your php.ini file. You would either need to set it to off, or check for magic_quotes_gpc() when escaping string data, and if it's ON, run stripslashes() on the data.

 

if( get_magic_quotes_gpc() ) {
$data = stripslashes($data);
}
$data = mysql_real_escape_string($data);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.