homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Storing PHP into a MySQL database
trying to retrieve the php code on a database

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

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)

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)

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)

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


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

If you had:

$code = "<html>


Would that print out correctly?


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

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved