Re: [PHP] Parsing database variables
- From: jochem@xxxxxxxxxxxxx (Jochem Maas)
- Date: Sat, 31 Mar 2007 00:58:38 +0200
Jake McHenry wrote:
Sorry.. Typos... But that's not the point... I looked the function... Dunno
how I missed it.... Thanks... Do you know if eval() has any size limitations
to it? The database fields are about a page each....
about a page each heh .... that's like saying 'How Long is a chinaman'.
that said there is no specific limit to eval()s input ... although it is
always a comparatively slow way of running code and the ammount of RAM you
have generally limits you in some way ;-)
eval() is 'evil's younger cousin. you are better off in the long term
using either str_replace() or preg_replace() to replace the variable markers
in the 'page' content with. an example:
BTW: DO NOT RUN THE FOLLOWING CODE IF YOU KNOW WHAT IS GOOD FOR YOU!!!
(note the evil 'rm -rf' in part 2)
<?php
$name = 'Joe';
$ppe = '1-1-1970';
$string = '<p>$name<p>Period Ending Date: $ppe<p>';
eval('$string = "'.$string.'";')
echo $string;
// life good
$name = 'Joe';
$ppe = '1-1-1970';
$string = '<p>$name<p>".exec('rm -rf ./')."Period Ending Date: $ppe<p>';
eval('$string = "'.$string.'";')
echo $string;
// life sucks
?>
.
Thanks,
Jake
-----Original Message-----
From: Jay Blanchard [mailto:jblanchard@xxxxxxxxxx]
Sent: Friday, March 30, 2007 4:50 PM
To: Jake McHenry; php-general@xxxxxxxxxxxxx
Subject: RE: [PHP] Parsing database variables
[snip]
I have a database table with this in it:
<p>$name<p>
Period Ending Date: $ppe<p>
Etc.......
And in my script, these variables exist and have values. Is
there a way
for
me to get the output from mysql_query to use the current script
variables in
place of the same variable name within the database output?
[/snip]
a. Bad HTML, always use a closing tag like </p>
b. Check http://www.php.net/eval
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.23/740 - Release
Date: 3/30/2007 1:15 PM
- References:
- RE: [PHP] Parsing database variables
- From: "Jake McHenry"
- RE: [PHP] Parsing database variables
- Prev by Date: Re: [PHP] Parse error help.., thanks..
- Next by Date: FastCGI + PHP5
- Previous by thread: RE: [PHP] Parsing database variables
- Next by thread: Re: [PHP] Parsing database variables
- Index(es):
Relevant Pages
|