Page 2 of 2

Posted: Wed Jun 23, 2004 4:59 am
by feyd

Code: Select all

eval('return "'.str_replace('"','"',$msg).'";');
I think...

Posted: Wed Jun 23, 2004 5:01 am
by feyd
bump (to fix the replies count)

Posted: Wed Jun 23, 2004 5:06 am
by Archy
do, it should be:

Code: Select all

<?php 

include('admin/header.php'); // get connection information 

$row = mysql_fetch_array($rs); 
$msg = $row['public'];

eval('return "'.str_replace('"','"',$msg).'";');

include('admin/strings.php'); 

echo($msg); 

?>

Posted: Wed Jun 23, 2004 5:08 am
by feyd

Code: Select all

$output = eval(.....);
echo($output);

Posted: Wed Jun 23, 2004 5:13 am
by Archy
Warning: Wrong parameter count for str_replace() in /home/host/public_html/index.php on line 14

I'm guessing that cant be good :\

Posted: Wed Jun 23, 2004 5:15 am
by feyd
hmm... I wrote the correct number of arguments...

Posted: Wed Jun 23, 2004 5:56 am
by redmonkey

Code: Select all

<?php

$msg = <<<EOS
<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test</title>
</head>

<body>



<div align="center"><?php echo"test"; ?></div>


</body> 
EOS;

$msg = eval('?>' . $msg);

echo $msg;

?>
Works for me. I can also replace...

Code: Select all

$msg = eval('?>' . $msg);

echo $msg;
...with just.....

Code: Select all

eval('?>' . $msg);
If I wanted to the code to execute at that particular point in the script.

Note, I had to use standard code tags to stop the forum removing the '?>' with the snippet.

Posted: Wed Jun 23, 2004 9:57 am
by Archy
How did you get it to work, whenever i tried it, it came up with an error, and so did one of my friends.

Posted: Wed Jun 23, 2004 10:36 am
by redmonkey
I just ran the code snippet I supplied above.

Care to share the error message(s) you are getting?

Posted: Wed Jun 23, 2004 12:00 pm
by Archy
The was the code that i was using:

Code: Select all

<?php 

include('admin/header.php'); // get connection information 

$row = mysql_fetch_array($rs); 
$msg = $row['public']; 

$msg = eval('return "',str_replace('"','"'.$msg).'";'); 

include('admin/strings.php'); 

echo($msg); 

?>
And $msg contains this:

Code: Select all

<html> 

<head> 
<meta http-equiv="Content-Language" content="en-gb"> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 
<title>Test</title> 
</head> 

<body> 



<div align="center"><?php echo"test"; ?></div> 


</body>
The error that I get is: Parse error: parse error in /home/host/public_html/index.php on line 14

Posted: Wed Jun 23, 2004 12:02 pm
by markl999
str_replace('"','\"'.$msg)
should be
str_replace('"','\"',$msg)

Posted: Wed Jun 23, 2004 12:07 pm
by redmonkey
Archy wrote:The was the code that i was using:

Code: Select all

<?php 

include('admin/header.php'); // get connection information 

$row = mysql_fetch_array($rs); 
$msg = $row['public']; 

$msg = eval('return "',str_replace('"','"'.$msg).'";'); 

include('admin/strings.php'); 

echo($msg); 

?>
That's not the code snippet I offered.

Posted: Sun Jun 27, 2004 4:53 am
by Archy
redmonkey, what was the exact code you used for in the database, and on the actual page it's self, as I am still having dificulties with this.