Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display PHP code stored in MySQL Database

Tags:

php

mysql

I have mysql database with code in 1 of the fields

test test test <?php $_GET['location']; ?>  test test

I am accessing display file test.php?location=abc and displaying that record from database in the following way

 This is my <?php echo $row_display_content['location']; ?>

And the only result I have got is

This is my

have no idea how to make it works, so dynamic values may be displayed inside the text from database

like image 411
user974435 Avatar asked Mar 08 '26 01:03

user974435


1 Answers

Use the eval function. Btw, this is a terrible approach to whatever problem you're trying to solve.

http://php.net/manual/en/function.eval.php

Edit:

$code = 'test test test <?php $_GET[\'location\']; ?>  test test';

eval('?>'. $code);
like image 117
John Himmelman Avatar answered Mar 09 '26 14:03

John Himmelman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!