Page 1 of 1
PHP Code in database
Posted: Sat Sep 25, 2004 6:18 am
by anjanesh
I have this in the database as one of the row entries in the table :
Column is PHPCode
Script1.php?argc1=argv1&argc2=$ID
Code: Select all
$row=mysql_fetch_assoc($res);
$ID=5;
echo $row['PHPCode'];
But this outputs Script1.php?argc1=argv1&argc2=$ID when I want it to output Script1.php?argc1=argv1&argc2=5
Hows that possible ? Any function like parsePHP ?
Thanks
Posted: Sat Sep 25, 2004 10:47 am
by feyd
you'll need eval... a better solution would be to change that string to variable inside the string to something else.. like {ID}.. then you can str_replace it with your value.
Posted: Sat Sep 25, 2004 10:45 pm
by anjanesh
This is just one line in this case. What if there is an entire function stored in one of the rows in a MySQL table ?
str_replace() wouldnt help.
Code: Select all
function SomeFunc()
{
// ...code
}
Posted: Sun Sep 26, 2004 12:40 am
by feyd
there generally shouldn't be code stored in the database.
Posted: Mon Sep 27, 2004 5:03 am
by kettle_drum
I quite often store classes in the database and you just run them through eval() once youve grabbed the code and then you can use them. Find its good for auto-update of the users software as you dont have any trouble with file permissions on different systems.