Mega Code Archive

 
Categories / Php / MySQL Database
 

Escape String

Escapes a string for use in a mysql_query. <?php $item = "Laptop"; $escaped_item = mysql_escape_string($item); printf ("Escaped string: %s\n", $escaped_item); ?> Escape special characters in a string for use in a SQL statement, taking into account the current charset of the connection. <?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); $item = "Laptop"; $escaped_item = mysql_real_escape_string($item); printf ("Escaped string: %s\n", $escaped_item); ?>