Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Storing PHP into a MySQL database

trying to retrieve the php code on a database



11:43 pm on Jan 7, 2009 (gmt 0)

5+ Year Member

I'm using Ajax to make a connection to the server, and ofcourse it should interact with my php script, and the php script pulls info from a database.

However, it seems that the only info I can pull is either javascript or html. The php won't parse. when I try to retrieve the php stored on my table it doesn't do anything. But it works very well for javascript or html.

To make things more clearer: I'm using Ajax to load info into an empty div. I have about 6 divs that form my layout and they're all saved under a .php extension. Even if I remove the Ajax, the PHP is not being executed, while HTML or Javascript under the same circumstances runs well. I changed the table type/collation to utf general hoping it would make it work.

Help please.


1:39 am on Jan 8, 2009 (gmt 0)

5+ Year Member

You can't pull a server-side language from a database as far as I know, because if I'm not mistaken, you're probably echoing it. Anything you echo won't be compiled by the server, it will just be outputted to the web page. If you want to compile external PHP, you'll probably have to use include() and use a file, not database.


5:09 pm on Jan 8, 2009 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You could execute PHP code from a database if you use the eval [php.net] function. However, do so with extreme caution and if it was user-supplied content there is absolutely no way I would even consider using this function. I would never use eval on user-supplied data. You would have to be mad to consider it.


5:21 pm on Jan 8, 2009 (gmt 0)

10+ Year Member

eval( )
man those php guys thought of EVERYTHING :-)


7:27 pm on Jan 8, 2009 (gmt 0)

5+ Year Member

If you had:

$code = "<html>


Would that print out correctly?


8:52 pm on Jan 8, 2009 (gmt 0)

5+ Year Member

Thanks for all the input! Ya what I was trying to do was to create a guestbook , using Ajax and php, and when the user clicks submit the guestbook.php will send the info to a table. All this would've been in local page. But because I couldn't store php I had to remove the php from the database and put it in .php file. but when the user clicks submit it would take them to that php page, therefore breaking the Ajax "feel" I was looking for. I'll try the eval and see how that works. I'll get back to you with the results.

Featured Threads

Hot Threads This Week

Hot Threads This Month