RE: confused about eval()

From: Date: Sun, 28 Jan 2001 21:54:15 +0000
Subject: RE: confused about eval()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-37142@lists.php.net to get a copy of this message
I don't know if anybody is curious or not, but I found my own problem... I changed the following code: $cVar = addslashes( $qrNews[$cContentField . "Text"] ); eval( "<? " . $cVar . " ?>" ); to: $cVar = $qrNews[$cContentField . "Text"]; eval( $cVar ); SO basically I removed the addslashes() (which I thought were necessary since the code snippet had quotes in them) and the <? and ?> from the eval funciton call, and it works as expected.... Joseph E. Sheble a.k.a. Wizaerd Wizaerd's Realm Canvas, 3D, Graphics, ColdFusion, PHP, and mySQL http://www.wizaerd.com ================================= > -----Original Message----- > From: Joe Sheble (Wizaerd) [mailto:wizaerd@wizaerd.com] > Sent: Sunday, January 28, 2001 12:44 PM > To: General PHP List > Subject: confused about eval() > > > I have searched the archives, php.net and zend.com, and cannot > seem to come up with an answer as to why this isn't woking... > > I have the following code snippet stored in a database, and I'm > trying to eval it with this line of code: > > $cVar = addslashes( $qrNews[$cContentField . "Text"] ); > eval( "<? " . $cVar . " ?>" ); > > I've tried: > eval( $cVar . " ?>" ); > eval( "?> " . $cVar ); > > and I cannot get the code snippet to actually evaluate... here's > the output I actually do get: > > TCE's Canvas Chat (Java Applet) > if( !( $myFile = en( > > \"http://wizaerd.com/cgi-sys/mchat.cgi?channel=wizaerd.com\", > > \"r\" ))) { print( \"Cannot be opened\" ); exit; } while( !feof( > $myFile )) { $myLine = fgets( $myFile, 255 ); print( $myLine . \" > \" ); } fclose( $myFile ); > Parse error: parse error in Unknown on line 0 > > the code in the database is correct cuz I can drop it into a PHP > page and it runs as expected... > > Could somebody give me a hand with this? > Thanx > > > --- code as is in database ------- > if( !( $myFile = fopen( "http://wizaerd.com/cgi-sys/mchat.cgi?channel=wizaerd.com", "r" ))) { print( "Cannot be opened" ); exit; } while( !feof( $myFile )) { $myLine = fgets( $myFile, 255 ); print( $myLine . "<BR>" ); } fclose( $myFile ); Joseph E. Sheble a.k.a. Wizaerd Wizaerd's Realm Canvas, 3D, Graphics, ColdFusion, PHP, and mySQL http://www.wizaerd.com =================================

« previous php.general (#37142) next »