random1 Posted February 21, 2008 Share Posted February 21, 2008 Hey All, How can someone process the text e.g. <?php echo ("test only"); ?> as php code on a PHP page as a result from a MySQL DB query. I tried echo($databaseresult); but it just prints it as text. Am I missing something REALLY obvious? Link to comment https://forums.phpfreaks.com/topic/92365-php-code-from-mysql-database/ Share on other sites More sharing options...
pocobueno1388 Posted February 22, 2008 Share Posted February 22, 2008 Are you trying to actually print the name of the variable and not actually the value it contains? You would do this <?php echo '$databaseresult'; Link to comment https://forums.phpfreaks.com/topic/92365-php-code-from-mysql-database/#findComment-473250 Share on other sites More sharing options...
drisate Posted February 22, 2008 Share Posted February 22, 2008 I am not sure i understand your question ... But if i am right your asking how to use info from your db Well first you have to connect your self then you can use this if you would like only one info $username = @current(@mysql_fetch_assoc(@mysql_query("SELECT username FROM accounts WHERE id='$id'"))); echo "Your username is $username"; or you can do it like this is you wana have more then one info from your row or from multiple rows $check = mysql_query("SELECT * FROM accounts WHERE id='$id'") or die (mysql_error()); if (mysql_num_rows($check)) { while ($member= mysql_fetch_array($check)) { echo "Your username is $member[username] and your age is $member[age]"; } } Link to comment https://forums.phpfreaks.com/topic/92365-php-code-from-mysql-database/#findComment-473251 Share on other sites More sharing options...
nogray Posted February 22, 2008 Share Posted February 22, 2008 remove the <?php and ?> from the string and use eval function eval('some php code here'); Link to comment https://forums.phpfreaks.com/topic/92365-php-code-from-mysql-database/#findComment-473287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.