I want to escape all mysql special chars in a javascript string.
the escape() function does not work since it doesn't escape characters like +
Any suggestions?
I want to escape all mysql special chars in a javascript string.
the escape() function does not work since it doesn't escape characters like +
Any suggestions?
See the documentation on binding parameters in Firefox's documentation for storage.
You should never try to construct SQL statements on the fly with values inserted in them. By binding the parameters, you prevent possible SQL injection attacks since a bound parameter can never be executed as SQL.
var statement = dbConn.createStatement("SELECT * FROM table_name WHERE id = :row_id");
statement.params.row_id = 1234;
You could AJAX it to PHP and return the mysql_real_escape_str
ed value.
If you're escaping it for insertion into a database, you'll have to send it server-side anyway, right?