Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the equivalent javascript code for php's mysql_real_escape_string()?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThere isn't any, because strings that come from javascript are still considered 'user input' and should **never be inserted in your database directly**. Your serverside has to do additional validation. There are functions to encode URLs and stuff like that. **What are you trying to do**?
      singulars
    2. COWell, the PHP documentation says: *mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: `\x00`, `\n`, `\r`, `\`, `'`, `"` and `\x1a`.* So it should be trivial to implement this. But why do you need this? Don't think that only if you use it at the client side, you don't have to use it at the server side. **Never** trust user input (i.e. all data that is sent to your server).
      singulars
    3. COI don't know about the original asker but I'm doing this to convert data from a web app into a MySQL database. Just because someone wants to do something in javascript doesn't mean they're building a web site. I'm making a single HTML file that I can open locally and click a button to generate MySQL insert statements and eventually some java code that will be pasted into an android app to setup a database. This will be rerun occasionally to generate database update scripts for future versions of the same android app.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload