Steve Angelis Posted February 15, 2008 Share Posted February 15, 2008 I am setting up a blog type of system for a website I am making and I have come across a much needed problem that must get fixed. What is the easiest way to remove quotation marks from posts? Probably when they are detected before entering into the database would be easiest, but any other ways would be good. Quote Link to comment Share on other sites More sharing options...
mem0ri Posted February 15, 2008 Share Posted February 15, 2008 Use the mysql_real_escape_string function :-) Quote Link to comment Share on other sites More sharing options...
Steve Angelis Posted February 15, 2008 Author Share Posted February 15, 2008 How would that work exactly? Quote Link to comment Share on other sites More sharing options...
mem0ri Posted February 15, 2008 Share Posted February 15, 2008 mysql_real_escape_string You'll need to have a database connection already open (though I assume that'll be the case as you mentioned you'll be inserting it into a database), and then you'll want to run: $text = mysql_real_escape_string($text); It will replace all special characters with escaped versions that store appropriately in MySQL. Quote Link to comment Share on other sites More sharing options...
Steve Angelis Posted February 15, 2008 Author Share Posted February 15, 2008 Ok sounds good. I am assuming that $text is just a variable representing all of the text I want checked out? And is it possible to have it as such, because I am also using BBCode with it and line breaking: nl2br(convert_bbcodes(mysql_real_escape_string($row['blog_message']))) Would that work still? I know the bbcode and line breaking does work with eachother already. Quote Link to comment Share on other sites More sharing options...
mem0ri Posted February 15, 2008 Share Posted February 15, 2008 As far as I can see, yes, that should work...and yes, $text is just a variable holding all of your text. Quote Link to comment Share on other sites More sharing options...
Steve Angelis Posted February 15, 2008 Author Share Posted February 15, 2008 Ok good. Thanx man Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.