Jump to content

Problem with htmlentities


doubledee

Recommended Posts

I can't seem to get htmlentities working in the code below...

echo "<textarea id=\"question" . $questionNo . " name=\"qaArray[\"answerText\"]\" cols=\"60\" rows=\"2\">" .
	(isset($questionNo) ? "htmlentities($qaArray[\"answerText\"], ENT_QUOTES" : "") .
	"</textarea>";

 

I tried using the default single quotes around answerText but that doesn't, nor do my escaped double quotes.

 

What is wrong?

 

Thanks,

 

 

Debbie

 

Link to comment
Share on other sites

I can't seem to get htmlentities working in the code below...

   echo "<textarea id=\"question" . $questionNo . " name=\"qaArray[\"answerText\"]\" cols=\"60\" rows=\"2\">" .
      (isset($questionNo) ? "htmlentities($qaArray[\"answerText\"], ENT_QUOTES" : "") .
      "</textarea>";

 

I tried using the default single quotes around answerText but that doesn't, nor do my escaped double quotes.

 

What is wrong?

 

Thanks,

 

 

Debbie

 

 

Look at the syntax highlighting

 

 

   echo '<textarea id="question' . $questionNo . '" name="'. $qaArray['answerText'] .'" cols="60" rows="2">' .
      (isset($questionNo) ? htmlentities($qaArray['answerText'], ENT_QUOTES) : '') .
      '</textarea>';

Link to comment
Share on other sites

How does this look...

<?php
	foreach($thoughtsArray as $questionNo => $qaArray){
		echo '<label for="question' . $questionNo . '">' . $questionNo . '.) ' . $qaArray['questionText'] . '</label>';
		echo '<textarea id="question' . $questionNo . '" name="' . $qaArray["answerText"] . '" cols="60" rows="2">';
		echo (isset($questionNo) ? htmlentities($qaArray['answerText'], ENT_QUOTES) : '');
		echo '</textarea>';
	}
?>

 

It seems to run okay.

 

 

Debbie

Link to comment
Share on other sites

Actually, the textarea NAME should be the ID or are you using the actual question text as the identifier for the textarea on processing?

<?php
foreach($thoughtsArray as $questionNo => $qaArray){
echo '<label for="question' . $questionNo . '">' . $questionNo . '.) ' . $qaArray['questionText'] . '</label>';
echo '<textarea id="question' . $questionNo . '" name="' . $qaArray['questionID'] . '" cols="60" rows="2">';
echo (isset($questionNo) ? htmlentities($qaArray['answerText'], ENT_QUOTES) : '');
echo '</textarea>';
}
?>

EDITED

Link to comment
Share on other sites

Actually, the textarea NAME should be the ID or are you using the actual question text as the identifier for the textarea on processing?

<?php
foreach($thoughtsArray as $questionNo => $qaArray){
echo '<label for="question' . $questionNo . '">' . $questionNo . '.) ' . $qaArray['questionText'] . '</label>';
echo '<textarea id="question' . $questionNo . '" name="' . $qaArray['questionID'] . '" cols="60" rows="2">';
echo (isset($questionNo) ? htmlentities($qaArray['answerText'], ENT_QUOTES) : '');
echo '</textarea>';
}
?>

EDITED

 

As I see it, this is how things should look...

<?php
	foreach($thoughtsArray as $questionNo => $qaArray){
		// Build Question.
		echo '<label for="question' . $questionNo . '">' . $questionNo . '.) ' . $qaArray['questionText'] . "\n";

		// Build Answer.
		echo '<textarea id="question' . $questionNo . '" name="' . $qaArray["questionID"] . '" cols="60" rows="2">';
		echo (isset($questionNo) ? htmlentities($qaArray['answerText'], ENT_QUOTES) : '');
		echo "</textarea>\n\n";
	}
?>

 

Yes, I changed name=$qaArray['question'] because that is what uniquely identifies a Question, and it is needed to write the Answer into the "answer" table...

 

 

Debbie

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.