Patrick3002 Posted March 10, 2007 Share Posted March 10, 2007 Heres my code: <?php $code=$_POST['code']; $code2 = str_replace('"','\"',$code); $code2 = str_replace('\\"','\"',$code); ?> <form id="form1" name="form1" method="post" action="convcod.php"> <table width="737" height="566" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="737" align="left" valign="top"> <textarea name="code" cols="120" rows="35" wrap="VIRTUAL"></textarea> </td> </tr> <tr> <td><?php echo "$code2"; ?></td> </tr> <tr align="right"> <td><br /><input type="submit" value="Convert" /></td> </tr> </table> </form> What im trying to do is change say <input type="hidden" name="sectionid" value="5" /> to <input type=\"hidden\" name=\"sectionid\" value=\"5\" /> or <table width="100%" border="0" cellspacing="0" cellpadding="2"> to <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\"> Basicly changeing all " to \" I've got it to do that but when i try and echo the new code, it echos the actual table and not the code. I need to it echo the actual code not display a table or input field... any help is greatly appreciated!!!! Quote Link to comment https://forums.phpfreaks.com/topic/42077-str-replace-help-urgent/ Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 Your going about that the wrong way. You need to change < to be < Try this: <?php $code=$_POST['code']; $code2 = str_replace('<','<',$code); ?> <form id="form1" name="form1" method="post" action="convcod.php"> <table width="737" height="566" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="737" align="left" valign="top"> <textarea name="code" cols="120" rows="35" wrap="VIRTUAL"></textarea> </td> </tr> <tr> <td><?php echo "$code2"; ?></td> </tr> <tr align="right"> <td><br /><input type="submit" value="Convert" /></td> </tr> </table> </form> Hopefully that is what you want. --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42077-str-replace-help-urgent/#findComment-204093 Share on other sites More sharing options...
Patrick3002 Posted March 10, 2007 Author Share Posted March 10, 2007 Nope, that was no good... Thank you though! Quote Link to comment https://forums.phpfreaks.com/topic/42077-str-replace-help-urgent/#findComment-204094 Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 http://www.aeonity.com/tstJs.php Worked out great for me? Am I missing something? --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42077-str-replace-help-urgent/#findComment-204097 Share on other sites More sharing options...
Patrick3002 Posted March 10, 2007 Author Share Posted March 10, 2007 I need to change all " to \" also, it doesnt work with that. Quote Link to comment https://forums.phpfreaks.com/topic/42077-str-replace-help-urgent/#findComment-204100 Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 Ah try this: <?php $code=$_POST['code']; $code2 = str_replace('<','<',$code); $code2 = addslashes($code2); ?> <form id="form1" name="form1" method="post" action="convcod.php"> <table width="737" height="566" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="737" align="left" valign="top"> <textarea name="code" cols="120" rows="35" wrap="VIRTUAL"></textarea> </td> </tr> <tr> <td><?php echo "$code2"; ?></td> </tr> <tr align="right"> <td><br /><input type="submit" value="Convert" /></td> </tr> </table> </form> can be viewed here: http://www.aeonity.com/tstJs.php --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42077-str-replace-help-urgent/#findComment-204101 Share on other sites More sharing options...
kenrbnsn Posted March 10, 2007 Share Posted March 10, 2007 The function the OP is looking for is htmlentities(). <form id="form1" name="form1" method="post" action="convcod.php"> <table width="737" height="566" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="737" align="left" valign="top"> <textarea name="code" cols="120" rows="35" wrap="VIRTUAL"></textarea> </td> </tr> <tr> <td><?php echo htmlentities($_POST['code'],ENT_QUOTES); ?></td> </tr> <tr align="right"> <td><br /><input type="submit" value="Convert" /></td> </tr> </table> </form> Ken Quote Link to comment https://forums.phpfreaks.com/topic/42077-str-replace-help-urgent/#findComment-204117 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.