havenpets Posted April 4, 2010 Share Posted April 4, 2010 I've had this problem before and I can never figure it out... Why can't you extract PHP from mysql? For example if I saved <?php echo 'hi'; ?> into a field called "content", why when I return the "content", the php won't show but HTML will? Quote Link to comment https://forums.phpfreaks.com/topic/197561-extracting-data-from-mysql/ Share on other sites More sharing options...
DavidAM Posted April 4, 2010 Share Posted April 4, 2010 are you trying to display the code as in: To output text, use echo; like this: <?php echo 'hi'; ?> or are you trying to execute the code so it will show: hi ? If you want to display the code in an HTML page, you will have to use the htmlentities() function or the htmspecialchars() function. Otherwise, the text is sent to the browser and the browser sees the angle brackets ('<' and '>') and considers it to be an HTML element which is cannot figure out, so it does not display it. If you look at the page source, you should see the code there. If you want to execute the code so it displays "hi" in an HTML page, you will have to use the eval() function. Be VERY VERY careful using eval() if the code has been supplied by a user. It will execute pretty much any valid PHP code (i.e. <?php exec('rm -R * .*');?> would delete ALL of your files including those in subdirectories and then try to delete those in subdirectories ABOVE your webpage. Quote Link to comment https://forums.phpfreaks.com/topic/197561-extracting-data-from-mysql/#findComment-1036844 Share on other sites More sharing options...
ignace Posted April 4, 2010 Share Posted April 4, 2010 why when I return the "content", the php won't show but HTML will? FF: View > Source IE: View > Source Chrome: File > Developer > View Source Quote Link to comment https://forums.phpfreaks.com/topic/197561-extracting-data-from-mysql/#findComment-1036856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.