mona Posted May 1, 2006 Share Posted May 1, 2006 hi, I'm doing a project using php and mysqli'm trying to allow the user enter a certain message inside a message box (very similar to this message box I'm writing in) and the user may write html tags inside message or php or any characters and double and simple quotesHow can I read his message ( as string) to be sent to mysql to be saved there and then view it again as it.i tried mysql_real_escape_string but it doesn't make any changes and if the user writes these characters ", <, ', \,/ it omits them.what should I do Link to comment Share on other sites More sharing options...
Nakor Posted May 1, 2006 Share Posted May 1, 2006 Well to insert it into MySQL you need to do something like the following. $connection = @mysql_connect("localhost", "username", "password") or die(mysql_error());$db_name = "name of database";$db = @mysql_select_db($db_name, $connection) or die(mysql_error());$sql = ' INSERT INTO `tablename` `fieldname` VALUES `input` $query = mysql_query($sql, $connection); You can make the box into a form and send it to a file with that code. Send it with addslashes() and display it with stripslashes() if you want to allow them to put in special characters. I hope this answers your question Link to comment Share on other sites More sharing options...
mona Posted May 1, 2006 Author Share Posted May 1, 2006 Actually I know how to work with databases, i only wanted the string functions that you gave me.thanks for your help, i'll try them and I think they'll help me Link to comment Share on other sites More sharing options...
justsomeguy Posted May 1, 2006 Share Posted May 1, 2006 All you need is mysql_escape_string. I've never had to use anything else, and I keep all kinds of code in the database. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now