MySql insert binary data to db without errors

后端 未结 3 1288
夕颜
夕颜 2021-01-16 10:50

I have a problem. When I do an insert like so in php:

sql = \"INSERT INTO mytable (id, value)
VALUES (\'sds83\',\'\".$EncryptedString.\"\')\";
3条回答
  •  独厮守ぢ
    2021-01-16 11:19

    Use PDO (or another database layer) that supports prepared statements.

    When you use query parameters instead of executing raw SQL, you gain speed improvements (the database only has to plan and optimize for one query) and all the data you write to it's parameters are immediately and completely isolated from the query itself.

    It's surprising how many people don't have this in place! Take the initiative and update your code.

提交回复
热议问题