You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe I missed some information, but if string contains a quote, you will get a fatal error
login := "hack"er"
db.Query("SELECT * FROM users WHERE login = "?s"", login)
Received #1064 error from MySQL server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"er' at line 1"
How can I safely insert any strings?
The text was updated successfully, but these errors were encountered:
db.Query performs string query. It doesn't parse any format string and knows nothing about placeholders. It simply pass its arguments to fmt.Sprintf (in very old version you need to do this manually).
I strongly recommend use prepared statements for queries that need some arguments. It is safer than perform text query. Nowadays, text queries should be used only for very simple queries.
Maybe I missed some information, but if string contains a quote, you will get a fatal error
login := "hack"er"
db.Query("SELECT * FROM users WHERE login = "?s"", login)
Received #1064 error from MySQL server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"er' at line 1"
How can I safely insert any strings?
The text was updated successfully, but these errors were encountered: