PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
evilcoder
Forum Contributor
Posts: 345 Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia
Post
by evilcoder » Tue Dec 09, 2003 9:16 pm
hey there.
I have a database field that contains php code. I'd like to know why when on my mainpage that extracts this database entry that the command isnt executed?
Is there a way to pre-parse the code so that it does execute, or is code in a database entry useless?
thanks guys.
Nay
Forum Regular
Posts: 951 Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia
Post
by Nay » Tue Dec 09, 2003 11:30 pm
You can have the PHP code from the database extracted into a variable, then is then parsed. Look into
parse_str() .
-Nay
evilcoder
Forum Contributor
Posts: 345 Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia
Post
by evilcoder » Wed Dec 10, 2003 2:35 am
i still cant work it out. That parse_str makes no sense to me.
Nay
Forum Regular
Posts: 951 Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia
Post
by Nay » Wed Dec 10, 2003 2:44 am
Okay, say this code is in the database:
Okay, so PHP just looks at it like:
Code: Select all
$rows['the_row'] = "\$name = "nay"";
So it's "unparsed". So you can parse_str($rows['the_row']), and then you can echo $name and
nay would be printed out.
Get me?
-Nay
evilcoder
Forum Contributor
Posts: 345 Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia
Post
by evilcoder » Wed Dec 10, 2003 3:13 am
yep, i'll try it when i get home, just finished here. Thanks Nay
Nay
Forum Regular
Posts: 951 Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia
Post
by Nay » Wed Dec 10, 2003 3:36 am
All in a days job
.
*flies away wearing underwear on the outside*
-Nay
aquila125
Forum Commoner
Posts: 96 Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium
Post
by aquila125 » Wed Dec 10, 2003 8:29 am
eval($row['phpcode'])