PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jun 23, 2004 4:59 am
Code: Select all
eval('return "'.str_replace('"','"',$msg).'";');I think...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jun 23, 2004 5:01 am
bump (to fix the replies count)
Archy
Forum Contributor
Posts: 129 Joined: Fri Jun 18, 2004 2:25 pm
Location: USA
Post
by Archy » Wed Jun 23, 2004 5:06 am
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);
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jun 23, 2004 5:08 am
Code: Select all
$output = eval(.....);
echo($output);
Archy
Forum Contributor
Posts: 129 Joined: Fri Jun 18, 2004 2:25 pm
Location: USA
Post
by Archy » Wed Jun 23, 2004 5:13 am
Warning: Wrong parameter count for str_replace() in /home/host/public_html/index.php on line 14
I'm guessing that cant be good :\
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jun 23, 2004 5:15 am
hmm... I wrote the correct number of arguments...
redmonkey
Forum Regular
Posts: 836 Joined: Thu Dec 18, 2003 3:58 pm
Post
by redmonkey » Wed Jun 23, 2004 5:56 am
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.....
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.
Archy
Forum Contributor
Posts: 129 Joined: Fri Jun 18, 2004 2:25 pm
Location: USA
Post
by Archy » Wed Jun 23, 2004 9:57 am
How did you get it to work, whenever i tried it, it came up with an error, and so did one of my friends.
redmonkey
Forum Regular
Posts: 836 Joined: Thu Dec 18, 2003 3:58 pm
Post
by redmonkey » Wed Jun 23, 2004 10:36 am
I just ran the code snippet I supplied above.
Care to share the error message(s) you are getting?
Archy
Forum Contributor
Posts: 129 Joined: Fri Jun 18, 2004 2:25 pm
Location: USA
Post
by Archy » Wed Jun 23, 2004 12:00 pm
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
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Wed Jun 23, 2004 12:02 pm
str_replace('"','\"'.$msg)
should be
str_replace('"','\"',$msg)
redmonkey
Forum Regular
Posts: 836 Joined: Thu Dec 18, 2003 3:58 pm
Post
by redmonkey » Wed Jun 23, 2004 12:07 pm
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.
Archy
Forum Contributor
Posts: 129 Joined: Fri Jun 18, 2004 2:25 pm
Location: USA
Post
by Archy » Sun Jun 27, 2004 4:53 am
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.