Jump to content

special string problem


mona
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...