Hello everybody I want to avoid the errors that occur when I post a text that contain the ' sign and put it in a mysql query
someone told me that theres a function in php to do that
but I want to use it manually because he told me that this function doesnt allow much encoding types such as persian and arabic
I tried the following code:
require("database_connection.php"); //to handle the connection to the database $GivenVar = str_replace("'","\\'",$GivenVar); //to replace the normal ' with \\' so that mySQL recognizes it as \' and works mysql_query("insert into mytable(text) values('$GivenVar')",$my_connection); echo 'Success!';
but there was no result and the message that says 'Success!' didnt appear!