Php > Databases
Mysql escape string
Mysql escape string A big hole in PHP's mysql support: the lack of mysql_escape_string function. Wondered what the easiest way of taking any zero-terminated string (i.e. one with single/double quotes, commas, special chars) and putting it in an SQL statement so it ALWAYS WORKS? Use this version of mysql_escape_string; based on the formal MySQL escape charater definition found at www.mysql.com. Example : ======== //put any chars you like in $un and $pw $sql=sprintf("insert into users (username, password) values(\"%s\",\"% s\")",mysql_escape_string($un), mysql_escape_string($pw));
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage