473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

eval'


I am retrieving the following string from the database.

" and upper(gsa_template_data_header) >= '".$start_selection."' and upper(gsa_template_data_header)
<= '".$end_selection."' order by upper(gsa_template_data_header) asc"

What I want to do is, replace the $start_selection and $end_selection with the values in code.

I am doing this with the following code and it complains on call to eval. Can someone point out the error?
$middle_conditions = " and upper(gsa_template_data_header) >= '.\$start_selection.' and
upper(gsa_template_data_header) <= '.\$end_selection.'
order by upper(gsa_template_data_header) asc";

$new_middle_conditions = "";
$tok = strtok($middle_conditions,".");
while ($tok) {
if (strstr($tok, "$")==true)
{
eval ("$new_middle_conditions .=".$tok.";");
}
else
{
$new_middle_conditions .= $tok;
}
$tok = strtok(".");
}

if ($middle_conditions != "")
$middle_conditions = $new_middle_conditions;
Thanks,

--
-Ankur Gupta
Jul 17 '05 #1
1 1691

On 11-Nov-2003, Ankur Gupta <ag****@cc.gatech.edu> wrote:
$middle_conditions = " and upper(gsa_template_data_header) >=
'.\$start_selection.' and
upper(gsa_template_data_header) <= '.\$end_selection.'
order by upper(gsa_template_data_header) asc";

$new_middle_conditions = "";
$tok = strtok($middle_conditions,".");
while ($tok) {
if (strstr($tok, "$")==true)
{
eval ("$new_middle_conditions .=".$tok.";");
}
else
{
$new_middle_conditions .= $tok;
}
$tok = strtok(".");
}

if ($middle_conditions != "")
$middle_conditions = $new_middle_conditions;


Your code would work if you change the eval to the following:
eval ("\$new_middle_conditions .=".$tok.";");
because you weren't escaping the $ the variable $new_middle_conditions was
replaced in the string giving you the eval error.

However, you could also replace all of your code with
eval("\$middle_conditions = \"$middle_conditions\";");
The eval can process the whole string at once, there's no need for you to
parse it.

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Reply Via Newsgroup | last post by:
This might sound sad... someone requesting a disertation on the 'eval' statement... but... I've been reading someone else's post - they had a huge calander like script and a handful of folk cursed...
11
by: sneill | last post by:
I have read a number of posts on the use of eval() in Javascript, and I agree that its use is questionable. But it does beg the following question: "How arbitrary does a string need to be before...
0
by: Michelle Keys | last post by:
Subject: DataBinder.Eval Error! Server Error in '/MSPOS' Application. ------------------------------------------------------------------------ -------- DataBinder.Eval:...
18
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
15
by: manstey | last post by:
Hi, I have a text file called a.txt: # comments I read it using this:
3
by: Pauljh | last post by:
Hi All, I'm running some javascript over a server side generated web page and have multiple generated empty select statements, that I want to populate when the page is loaded. As HTML doesn't do...
4
by: Jm lists | last post by:
Hello members, I want to know does the "eval" in python have the same features as in Perl (capture errors)? For example,in perl I can wrote: $re = eval { 1 / 0 }; Though 1/0 is a fatal...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
5
by: wendallsan | last post by:
Hi all, I'm running into a situation where it seems that JS stops executing as soon as I call an eval in my script. I have an Ajax.Request call to a PHP page that builds a JS object and returns...
10
by: Gordon | last post by:
I have a script that creates new objects based on the value of a form field. Basically, the code looks like this. eval ('new ' + objType.value + '(val1, val2, val3'); objType is a select with...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.