Jump to content

php heredoc or some thing i dont know anymore


optikalefx

Recommended Posts

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 &#60;p&#62;<br><br>

to type an apostrophe type &#38;#39;<br><a href='http://www.4tenproductions.com/exp.htm'><font size='1'>Why?</font></a><br>

example:        Don&#38;#39;t     =      Don&#39;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>";

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.