Jump to content
wantabe2

Code hepl needed to find & replace characters

Recommended Posts

update super
set `name` = REPLACE(`name`, ',' , ' ')

I have the following code that removes the comma in a MySQL database column & replaces it with a blank. In the above example, the database is named super & the column is named name. This code works great but currently I'm running the script each day & changing it to also remove periods, question marks, etc. Is there a way I can edit the above code that will not only find & replace the , with a blank space, but edit it so it will find the periods, commas, question mark, exclamation mark, etc all in one run? Please help as I am currently editing the above code to numerous other things to find & replace daily. Thank

 

 

Share this post


Link to post
Share on other sites

Why on earth do you keep storing punctuation marks only to replace them daily?

 

Why are those characters even a problem? And if they are, why do you not reject or replace them immediately when you receive the input?

Share this post


Link to post
Share on other sites

Short answer is I DO NOT know how to limit the input of those characters in the code as well as I DO NOT want to know as I am not a programmer nor want to be or pretend to be one. I do work in IT in a totally different realm. The only reason I have been task to do this, is because I have time to do it. With that said, I hope I answered your questions, in hoping someone else will respond instead of getting the third degree with more questions as to how or why I do what I do!!

Share this post


Link to post
Share on other sites

The smarter way would be to write a PHP function that does your editing to an argument that is passed to it. Then you could use that "corrected" variable in your update query. The beauty is that the function can be used prior to any query statement you write instead of having to modify every query statement when you decide to remove something new!

Share this post


Link to post
Share on other sites

This is not acceptable behavior. Thread pruned.

Share this post


Link to post
Share on other sites
Guest
This topic is now 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.