/    Sign up×
Community /Pin to ProfileBookmark

eval statement

I have the following block of code on our site. We have 3 webservers our site uses. 2 of the webservers are using PHP version 4.0.3pl1 and the othere is running 4.3.3. The code below works on 4.0.3.pl1, but I get an error on the 4.3.3 version. Can someone please help me.

[code]
$NOMAPSFOUND=0;
$map=array();

if (!strlen($sErr)) {
$myQuery=$myHost.$myVars;
$fd= @fopen ( $myQuery, “r”);
if (!$fd) {
$sErr=”Error: Couldn’t complete MAP request. Please try again
later.”;
} else {
$myResults = fread( $fd, 500000 );
fclose( $fd );

eval( “?>$myResults” );
}
}
[/code]

[b]Error:[/b]
Parse error: parse error, expecting `’)” in /home/httpsd/ra-new/stores/locator/show_store_map.php(132) : eval()’d code on line 9

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@ExuroJan 19.2004 — Which line in your code was the error on? It looks like you just took a chunk out of the file and pasted it here. Knowing where the error was supposed to be might help, especially since we can't run this ourselves without the whole script... Also, do you really need the buffer on your fread to be 500000? That will seriously slow down your script. If you don't have any lines in the files you're reading from that are that long I'd highly recommend shortening that.
Copy linkTweet thisAlerts:
@jrthor2authorJan 19.2004 — the error is on the eval code line
Copy linkTweet thisAlerts:
@ExuroJan 20.2004 — Wow, sorry! I looked for an eval() in there but I didn't see one, but I see it now. I'd say it is probably not getting an error from that actual code, but rather from what it is trying to evaluate. Whatever it's trying to read from the file probably isn't syntactically correct. That's my best guess...
Copy linkTweet thisAlerts:
@jrthor2authorJan 20.2004 — but then shy would this work on a lower version of php than what's on this 1 server? Is there another command other than eval that I could use?
Copy linkTweet thisAlerts:
@jrthor2authorJan 20.2004 — anyone have any suggestions??
Copy linkTweet thisAlerts:
@ExuroJan 20.2004 — Is there any way that you could find out exactly what the value of $myResult is at the point when the script errors? Maybe you could write everything out to another file, and the last entry would be what the PHP choked on. It would help to actually see what $myResult is though...
×

Success!

Help @jrthor2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...