Jump to content

Some help


fxuser

Recommended Posts

Hello,

 

i have a mysql query using LIKE .. so what i saw is that when i type % , < , \ , _ i can easily show all the results of the query..

 

what i want to do is when i type these in the input to replace them with ""

 

so what i have tried is :

 

$bad_symbols = array("/%/", "/_/", "/</");
$newvar = preg_replace($bad_symbols, " ", $to);

 

but just the first two seem to work , also how can i add the "\" in the array?

 

thanks

Link to comment
Share on other sites

Someone with more experience may have another idea but can you use something like str_replace before you enter the variables into the query?

 

i have tried it but i get the same problem the "<" doesnt get replaced with " " and i cant put inside the array the "\".

Link to comment
Share on other sites

Are you converting the text using html entities or anything?

 

i had a function that checks for my inputs and it seems it was strip_tags()

I just tested it and it does indeed work, as evidenced by the string before and after using str_replace on it. Did you bother to try it before deciding it wouldn't work?

 

i have tried a similar way before your response but i also tried what you posted and it seems the strip_tags() was the problem.

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.