optikalefx Posted July 30, 2007 Share Posted July 30, 2007 I have a textarea that people write text into, and its updated into a database, and then displayed on a website. The text is also loaded from the database into the form in order for you to edit it. The problem is that you cant use apostrphes in the text. because that makes php end the line. but i need to be able to use apostrphes. What happens is that when i type in info, if it has an apostrophe it will just return unchanged. this is a problem. here is the code to load the data into the textarea: <FORM METHOD="POST" ACTION="http://www.4tenproductions.com/jrinput.php"> <?php $con = mysql_connect("xxxx","xxxx","xxxx"); mysql_select_db("update1", $con); $team = $_POST["teamchoice"]; $table = $_POST["table"]; $sql = mysql_query("SELECT value FROM $table WHERE fname='$team'"); while($row = mysql_fetch_array($sql)) { $text = $row['value']; } echo <<<EOT <table border='0' width='100%' height='100%'><tr><td valign='middle' align='center'> <table border='0' cellpadding=10><tr><td> <TEXTAREA NAME='teampage' ROWS=36 COLS=80>$text</TEXTAREA></td> <td valign='middle' align='center'> <h5><u>Helpful Hints</u></h5><br><br> To start a new paragraph type <p><br><br> to type an apostrophe type &#39;<br><a href='http://www.4tenproductions.com/exp.htm'><font size='1'>Why?</font></a><br> example: Don&#39;t = Don't<br> <h5>Note: when you update the page the apostrophe will show up as a normal apostrophe</h5> </td></tr></table> <br><center> <INPUT TYPE='submit' value='Update'> <INPUT type='hidden' name='teamchoice' value='$team'> <INPUT type='hidden' name='table' value='$table'> EOT; ?> </td></tr></table></form> right now i have it explaining to use the html escape command to use apostrphes, but that isnt good enough becuase when you load the data back they dont show up as the escape they show up as an apostrophe, so if you update again its wrong. and i shouldnt have to change all the apostrphes everytime i update the page. this is the input php file. <?php $con = mysql_connect("xxxx","xxxx","xxxx"); mysql_select_db("update1", $con); $myText = $_POST["teampage"]; $team = $_POST["teamchoice"]; $table = $_POST["table"]; $sql = mysql_query("UPDATE $table SET value = '$myText' WHERE fname = '$team'"); echo "<table border='0' width='100%' height='100%'><tr><td valign='middle' align='center'>"; echo "<form method='post' action='http://www.4tenproductions.com/jrform.php' target='form'>"; echo "<INPUT type='hidden' name='table' value='$table'>"; echo "<INPUT type='hidden' name='teamchoice' value='$team'>"; echo "<input type='submit' value='Updated. Go Back'></form></tr></td></table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/62556-php-heredoc-or-some-thing-i-dont-know-anymore/ Share on other sites More sharing options...
trq Posted July 30, 2007 Share Posted July 30, 2007 $myText = mysql_real_escape_string($_POST["teampage"]); Quote Link to comment https://forums.phpfreaks.com/topic/62556-php-heredoc-or-some-thing-i-dont-know-anymore/#findComment-311423 Share on other sites More sharing options...
optikalefx Posted July 30, 2007 Author Share Posted July 30, 2007 AHHHH THANKYOU SOOOO MUCH!! I was using that line for a while, but i was using it wrong, it works now, i really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/62556-php-heredoc-or-some-thing-i-dont-know-anymore/#findComment-311428 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.