mysql - SQL - Changing " or ' in SQL so adding text is easier -


So I am creating a database of all my text messages to get information about my habits and There is a problem of importing whenever there are apostrophes (often) or quotation marks (as you might think is not as rare), I get the issue of syntax.

Is there a way to use MySQL to use something else other than adding "or" strings, in particular, the field is a VAARAAR). If I could use my ~ ~ ~ ~ ~ ~ ~ ~ ~ or "some other" in a text message, then my life would be very easy.

Preferably you should use parameterized queries, then your database connector should correctly send the wire to the database .

If you want to ask questions by adding values ​​to a query, you need to avoid strings to make strings string structure in the SQL code.

Paste on a delimiter for strings, some Stringings and encryption marks around others, which only make them difficult to avoid properly. I recommend that you use approfopops, as the SQL standard specifies.

To avoid strings correctly strings bound by apostrophes, you should:

  • Change all backslashes by double backslashes, then
  • backslash and apostrophe gate

For example, to create a string , it is literally in a backslash (\). string with an "example" This should end in the query:

  Insert in the table (txt) values ​​('this' is an "example" with a backslash (\\)). ')  

Note: This is a perfect way to avoid wires for MySQL, to avoid other databases, you can use different characters and other characters are required to escape. Therefore, using it for any other database may fail, or worse for attacks of SQL injection.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -