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

Link to comment
Share on other sites

  • 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.

:-* :-*

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.