mardirousi — 2012-01-09T20:20:20-05:00 — #1
I need to ensure no commas are saved in a particular MySQL table. Is there a way to do this within the database itself without using PHP code on the web server prior to the data being past to the DB? I was thinking perhaps a stored procedure (not sure if this is what they're called in MySQL). I would really appreciate any help on this.
r937 — 2012-01-10T03:06:31-05:00 — #2
before adding data to the database, i sincerely hope your application code checks for and prevents sql injection
that's where you can remove the commas as well
mardirousi — 2012-01-10T11:17:32-05:00 — #3
Good point. The application is checking to prevent sql injections. I will begin there. Thanks for pointing me in the right direction.
tony_tonic — 2012-01-30T16:42:54-05:00 — #4
INSERT INTO tablex VALUES (REPLACE("mycomma,test text, haha", ",", " "));
that should work I think.
But yes, you should really clean the inputs before you get to this stage.