Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 11-18-2009, 03:39 PM Store PHP in MySQL?
WebTraffic's Avatar
Extreme Talker

Posts: 225
Name: Brandon
Trades: 0
I know that you are able to put html in a database...

I am trying to put php in my database so that I can pull php scripts from my database. Is it possible to do this?

Example... when I add <font color="green">This is a test</font> to a table in my database, the website pulls it just fine. However, if I put echo "This is a test"; in my database it will not pull it.

I need to put php inside my database
__________________

Please login or register to view this content. Registration is FREE

Coding is just like a woman. If you don't do something exactly right, it complains.
WebTraffic is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-18-2009, 03:44 PM Re: Store PHP in MySQL?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
php HAS to be parsed through the interpreter, read up on the eval() function.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-18-2009, 03:46 PM Re: Store PHP in MySQL?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
In order to parse stored php code, you would need to run it as a string through the eval() function. This site stores the templates files (including php) within a database.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 11-18-2009, 04:09 PM Re: Store PHP in MySQL?
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
Just a note about using eval:

Any output in eval'd code will have no effect. For example:
PHP Code:
$code 'echo "hello world";';
eval(
$code); 
The above code will have no output. If you want your eval'd code to have output you'll need to capture it manually using the output control functions:

PHP Code:
$code 'echo "hello world";';
$pre 'ob_start();';
$post '$myOutput = ob_get_clean();';
eval(
$pre $code $post);
echo 
$myOutput
In the above code we use an output buffer to capture the output of the code and store it in the variable $myOutput. Since variables persist after the code is evaluated we can then echo $myOutput outside of the eval statement.

Another note: your eval'd code should not begin with an opening tag (<?php).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 11-18-2009 at 04:11 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-18-2009, 06:12 PM Re: Store PHP in MySQL?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
I'm surprised that nobody told it sooner, but please, don't do that.
It's simply asking for troubles.

It's wastful on the resources. Each eval is like launching another PHP instance, with a new context, and context switching IS costly.

It's slow, because for each block of code, you have to make a call to the db. A db call (even for a small set of datas) is around 150 times slower than reading a file.
You will spend most of the time waiting for the db resultset and eval()'uating your content...

It's very, very difficult to debug and extremly prone to side effects.

If you are not very careful upon sql injection, it's a big door widely open, with tracking light and a flag saying "hackers welcome" and "please hit me real hard !"
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 11-24-2009, 12:36 AM Re: Store PHP in MySQL?
freezea's Avatar
Experienced Talker

Posts: 45
Trades: 0
Hi.
I think you can get what you want here.
http://www.scriptsearch.com/details/10415.html
__________________

Please login or register to view this content. Registration is FREE
: Web-based Excel-like Java reporting tool.
freezea is offline
Reply With Quote
View Public Profile
 
Old 11-25-2009, 04:32 AM Re: Store PHP in MySQL?
Novice Talker

Posts: 8
Name: Sean
Trades: 0
Why would you put PHP code in MySQL, why not just have a libary of PHP scripts in a folder and call them as includes into your page as needed (that's usually what people do).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
thepromoshop is offline
Reply With Quote
View Public Profile
 
Old 11-25-2009, 04:24 PM Re: Store PHP in MySQL?
Junior Talker

Posts: 1
Trades: 0
use the bbcode
68kb is offline
Reply With Quote
View Public Profile
 
Old 11-27-2009, 02:56 PM Re: Store PHP in MySQL?
Banned

Posts: 12
Trades: 0
Slow or not you can get around MOST mysql injection attacks by putting your query through mysql_real_escape_string or the improved mysqli_real_escape_string

If you're allowing user input like this and it's not just a private system for yourself (that's locked away) there's a whole lot more to check for like to make sure they're input isn't linking to malicious sites via hidden iframes or whatever they might do. Doing so they could attack your website visitors using your website to do it.
chrisrich is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Store PHP in MySQL?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29573 seconds with 12 queries