Interested in improving this site? Please check the To Do page.

Back to MySQL Verbs

mysql.escapeString

Escape special characters in a string for use in an SQL statement.

Syntax

mysql.escapeString(dbid, string)

Params

A database connection ID and a query string.

Returns

A string containing the cleaned up query

Examples

sql = "select * from somedata where somefield = 'What's this?'"
s = mysql.escapeString(id, sql)
dialog.alert(s)
	 ยป select * from somedata where somefield = \'What\'s this?\'

Notes

Note that dbid must be a valid, open connection. This is needed because the escaping depends on the character set in use by the server.

See Also


Personal Tools