Dolphin.com.bd

Programming Language => Web based Developer Forum => Topic started by: bbasujon on January 22, 2012, 07:45:34 AM

Title: Apostrophe s (‘s) problem in MySQL query
Post by: bbasujon on January 22, 2012, 07:45:34 AM
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).

Example:

<form method=”post” action=”">
<input type=”text” name=”user_name” value=”wallpaperama’s”>




<input type=”submit” name=”Submit” value=”Submit”>
</form>

<?php
$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.