rbastien Posted March 21, 2007 Share Posted March 21, 2007 Hey, I have a textarea that sends the text to the database. <textarea name="example" method="post" /> The problem is that if the text contains anything that will obstruct the php coding (such as a quotation mark, a semicolon, bracket, etc...) it processes it, and results in a MYSQL error. The database row is set to VARCHAR NOT NULL. @extract($_REQUEST); mySqlconnect(); mysql_query("INSERT INTO table(id, artist, song) VALUES ('5', '$artistname', '$songname')"); It works perfectly without using any characters that will interrupt the code. Will i have to insert a backslash every time I use a special character, or is there an easier way? Link to comment https://forums.phpfreaks.com/topic/43612-using-quotations-within-text-in-a-database/ Share on other sites More sharing options...
jitesh Posted March 21, 2007 Share Posted March 21, 2007 INSERT INTO table(id, artist, song) VALUES ('5', addslashes('$artistname'), addslashes('$songname')"); Then when you access data from database filter data by stripslashes These are PHP APIs addslashes stripslashes Link to comment https://forums.phpfreaks.com/topic/43612-using-quotations-within-text-in-a-database/#findComment-211797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.