single quotes in SQL Query

后端 未结 5 2198
半阙折子戏
半阙折子戏 2020-12-20 10:26

Im writing a php script that is used to update a database but it is giving errors when i tries to run the query it returns an error along the lines of

You h         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-20 10:44

    As you are using DB API directly (no DB abstraction level) the best solution is to use DB escape function.

    Just use mysql_real_escape_string().

    
    

    As a bonus you'll get a really improved security against SQL INJECTION attacs your previous code was prone.

    In the case you would simply escape slashes you have, again, to use php/mysql functions addslashes() will do the job in this case.

提交回复
热议问题