Author Topic: Apostrophe s (‘s) problem in MySQL query  (Read 2408 times)

bbasujon

  • Administrator
  • VIP Member
  • *****
  • Posts: 1827
  • I want to show my performance at any where
    • View Profile
    • Higher Education
Apostrophe s (‘s) problem in MySQL query
« 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.
Acquire the knowledge and share the knowledge so that knowing,learning then sharing - all are the collection