Developer Forums | About Us | Site Map
Search  
HOME > PHPMANUAL


Sponsors





Web Host
site hosted by netplex
Partners

Online Manuals

mysql_real_escape_string

(PHP 4 >= 4.3.0)

mysql_real_escape_string --  Escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection.

Description

string mysql_real_escape_string ( string unescaped_string [, resource link_identifier])

This function will escape special characters in the unescaped_string, taking into account the current charset of the connection so that it is safe to place it in a mysql_query().

Note: mysql_real_escape_string() does not escape % and _.

Example 1. mysql_real_escape_string() example

<?php
$item = "Zak's and Derick's Laptop";
$escaped_item = mysql_real_escape_string($item);
printf ("Escaped string: %s\n", $escaped_item);
 ?>

The above example would produce the following output:

Escaped string: Zak\'s and Derick\'s Laptop

See also mysql_escape_string() and mysql_character_set_name().

Copyright 2004-2024 GrindingGears.com. All rights reserved. Site hosted by NETPLEX