Code: Select all
str_replace('\'', '\\\'', $description)
So that "wasn't" becomes "wasn\'t" in the string, so that it does. And when I check in the MySQL console it does post the line to he db, but in my browser PHP returns the error:
Query: INSERT INTO timecard (name,customer,projectno,year,period,day, totaltime,fromtime,totime,description) VALUES ('Randy', 'Customer',11,2014,09,13,'01:00:00','12:00:00','13:00:00','Apache wasn\'t running correctly but has now been fixed ')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't running correctly but has now been fixed ')' at line 4
How do I get around this? If I recall correctly adding # in front of a line will make the browser skip any warnings or errors, but that would be a horrible idea for a MySQL Query error. Seems like I'm missing something obvious here but 'Google it' hasn't turned up any answers for me.
Any help would be appreciated, thanks.