mysql_real_escape_string with PDO PHP

后端 未结 3 1855
伪装坚强ぢ
伪装坚强ぢ 2020-12-22 08:21

Hello i am new to PDO so getting confused and getting errors ;) with mysql_real_escape_string ..

can any one help, here is my code

if(!empty($_POST)         


        
相关标签:
3条回答
  • 2020-12-22 08:44

    With prepared statements you don't have to escape your variables. The driver will do it for you automatically, depending on the database you are using underneath. Actually you mustn't escape it yourself, since this will double escape it.

    0 讨论(0)
  • 2020-12-22 08:48

    mysql_real_escape_string requires an active mysql connection made through a mysql_connect call previously... So yes, it won't work.

    PDO does that automatically for you anyway

    0 讨论(0)
  • 2020-12-22 08:55

    Yes, PDO automatically escapes your data, so you don't need to use mysql_real_escape_string. See here, for example.

    0 讨论(0)
提交回复
热议问题