How to insert a php code snippet in mysql database

后端 未结 3 1844
野的像风
野的像风 2020-12-22 06:25

I have a php code snippet like below :

function is_ancestor_of( $page_name = null, $post ) {

if(is_null($page_name))
return false;

// does         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-22 07:02

    Escape special characters using mysql_real_escape_string(). You'd probaply be better off moving away from mysql_* functions though and start using PDO or mysqli_* for example.

    Edit As mentioned in the comments, make sure you place the code as a string and that the DB field is the correct data type. Also, make sure you use mysql_real_escape_string() (if you insist on using mysql_*) on the whole string (or code).

提交回复
热议问题