News:

Dolphin Computers Ltd., is a leading IT product and service provider company in Bangladesh.

Main Menu

Apostrophe s (‘s) problem in MySQL query

Started by bbasujon, January 22, 2012, 07:45:34 AM

Previous topic - Next topic

bbasujon

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