How to insert a php code snippet in mysql database

后端 未结 3 1847
野的像风
野的像风 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条回答
  •  Happy的楠姐
    2020-12-22 07:22

    You will need to use mysql_real_escape_string() to escape the php code so it does not throw an error when inserting. Then you run an eval() on the statement, if you want it to execute. If you have a mixed html and php stored in the database you would call eval like so

     eval('?>'.$dbresult.'

    Just make sure you stripslashes() on the database result

提交回复
热议问题