Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Been stuck for 2 days...can't figure out how to use Eval() in database

Status
Not open for further replies.

sd0t1

IS-IT--Management
Mar 14, 2007
131
US
Well first, I'm inserting the record directly into MySql via myPhpAdmin. It gives me error unles I escape every single quoate except the first and last. This is how I have to put it in inorder to not get a mysql error.
Can anyone tell me why when view this page it shows up empty.

INSERT INTO content (title, body) VALUES ( "test page", "<?php eval(\"echo \"Hello World\";\");?>") ;

thanks.

 
Part of the problem may be with your eval(). What if you changed the double quotes around Hello World to single quotes. Or possibly double escape the quotes around Hello World.

Code:
INSERT INTO content (title, body) VALUES ( "test page", "<?php eval(\"echo 'Hello World';\");?>") ;

or

Code:
INSERT INTO content (title, body) VALUES ( "test page", "<?php eval(\"echo \\"Hello World\\";\");?>") ;

Not really sure about that last one though.

Ron Wheeler
 
Code:
INSERT INTO content (title, body) VALUES ( "test page", "<?php eval(\"echo \"Hello World\";\");?>") ;

i have no idea why you would want to do this. if you already know the data that needs to be put into the db why are you trying to eval it?

echo and print display text on the browser/terminal that is running the command. here you are trying to put text into a database.

aaah... i get it... you're going about things the wrong way. do not put the eval into the db. just the html. no echo no nothing just the html.

when you want to DISPLAY the page you use eval ("echo ...);

so your insert statement should look like this

Code:
$sql = "  INSERT INTO content (title, body) 
             VALUES ( 'test page', 'Hello World. You're name is $name')" ;

and your output would be

Code:
$command = "echo $row['body'] ;";
eval ($command);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top