hi guys,
am well confused by this one ... am trying to insert a piece of html code as a variable :
$code = "$rbel[mycode]";
$code = str_replace("\n", "", $code);
$code = str_replace("\r", "", $code);
$code = str_replace("'", "'", $code);
$code = str_replace('"', '"', $code);
$code = str_replace('<', '<', $code);
$code = str_replace('>', '>', $code);
echo'
<script type="text/javascript">
var code = "'; echo"$code"; echo'";
</script>
';
if i do the variable this way it echo's out in the html like so :
var code = "<P><TABLE style="BORDER-RIGHT: 0px; PADDING-RIGHT: 5px; BORDER-TOP: 0px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: 0px; WIDTH: 650px; PADDING-TOP: 5px; BORDER-BOTTOM: 0px; BORDER-COLLAPSE: separate" align=center><TBODY><TR><TD style="BORDER-RIGHT: #aaaaaa 1px dashed; BORDER-TOP: #aaaaaa 1px dashed; BORDER-LEFT: #aaaaaa 1px dashed; BORDER-BOTTOM: #aaaaaa 1px dashed"> Single Column Text Element</TD></TR></TBODY></TABLE></P>";
but refuses to work ??
if i type the variable in manually like :
$code = "$rbel[mycode]";
$code = str_replace("\n", "", $code);
$code = str_replace("\r", "", $code);
$code = str_replace("'", "'", $code);
$code = str_replace('"', '"', $code);
$code = str_replace('<', '<', $code);
$code = str_replace('>', '>', $code);
$code = "<P><TABLE style="BORDER-RIGHT: 0px; PADDING-RIGHT: 5px; BORDER-TOP: 0px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: 0px; WIDTH: 650px; PADDING-TOP: 5px; BORDER-BOTTOM: 0px; BORDER-COLLAPSE: separate" align=center><TBODY><TR><TD style="BORDER-RIGHT: #aaaaaa 1px dashed; BORDER-TOP: #aaaaaa 1px dashed; BORDER-LEFT: #aaaaaa 1px dashed; BORDER-BOTTOM: #aaaaaa 1px dashed"> Single Column Text Element</TD></TR></TBODY></TABLE></P>";
echo'
<script type="text/javascript">
var code = "'; echo"$code"; echo'";
</script>
';
it works perfectly, yet echo's out the same in the html ?
am sure its somthing to do with the way php is treating the string, but dont know how to fix it
any help would be greatly appreciated
Scooby