View Full Version : Parsing PHP from MySQL cells...
lord_raven
08-23-2003, 07:27 AM
Is it possible to parse PHP that is embeded in MySQL table cells? (preferably something server side)...
Can you clarify some more ?
Do you mean sort of compiling it so save on processing time when the PHP is parsed by the webserver ? What do you mean by 'embedded' ? I think you'll in any case need to first select the PHP, then (pre)compile it and then update the db-cell with the result.
Spookster
08-23-2003, 07:22 PM
Are you wanting to be able to execute PHP code that you have stored in your database?
lord_raven
08-23-2003, 08:16 PM
Originally posted by Spookster
Are you wanting to be able to execute PHP code that you have stored in your database? In short, yes...
firepages
08-24-2003, 02:55 AM
you can eval() the returned code...
<?
$result = mysql_query( "SELECT code FROM $table WHERE /*etc*/" ) ;
$row = mysql_fetch_array( $result , MYSQL_ASSOC ) ;
eval( $row['code'] ) ;
?>
lord_raven
08-24-2003, 05:06 AM
Cool, it worked... thank you...
Edit: As long as it looks like this in the DB cell...
## PHP STUFF HERE ##
?>
NON-PHP STUFF HERE
<?
firepages
08-24-2003, 01:18 PM
yes , should have mentioned that the eval() function automatically adds a '<?' to the beginning of the eval()'d string and a '?>' to the end , so if your code to be evaluated was say ..
'hello <?=$sweet;?> world'
then you would need to use this if you were to eval() it
'?>hello <?=$sweet;?> world<?'
looks like you got that sorted though :D
lord_raven
08-25-2003, 05:07 AM
If there's an error, it doesn't really give you any details... Oh, well, that's the the breaks...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.