apostrophe s ('s) problem in MySQL query

When you will work with your Blog or something in PHP, MySQL. Then your user may enter apostrophe s (‘s) into the post writing area. Then it will cause a problem for executing your MySQL Query. To execute your query for MySQL you can use mysql_real_escape_string($yourStrings).


<form method=”post” action=””>
<input type=”text” name=”user_name” value=”wallpaperama’s”>
<br />
<br />
<input type=”submit” name=”Submit” value=”Submit”>

$user_name = mysql_real_escape_string ($_POST[‘user_name’]);

and write your mysql query. It will be executed without any error. It’s more secured to post data to MySQL database.

For know more details please go to mysql_real_escape_string() in PHP Function Manual.


Shaharia is a professional software engineer with more than 10 years of experience in the relevant fields. Digital ad certified, cloud platform architect, Big data enthusiasts, tech early adopters.

Site Footer