escape quotes

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
Jay

Post by Jay » Mon Aug 19, 2002 8:55 am

Code: Select all

$TaskDescription = str_replace('"',""",$TaskDescription);

Just slip that in somewhere before you output it!

User avatar
WiZARD
Moderator
Moderator
Posts: 1256
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: escape quotes

Post by WiZARD » Mon Aug 19, 2002 10:31 pm

babyfighter wrote:I am trying to send a user-defined string as a hidden variable in a form. The string has single quotes and double quotes in it. When I attempt to pass the string and print it on the next page, it gets cut off mid-string due to the presence of the quotes in the string. Here is a little sample of what I'm doing:

<?php

print ("<INPUT TYPE=hidden NAME='TaskDescription' VALUE='".$TaskDescription."'>");

?>

//THEN ON THE NEXT PAGE I HAVE THIS CODE:

print ($TaskDescription);


Needless to say it's been very frustrating trying to solve this. Anybody have any quick solutions for this problem? Thanks a lot.

try this:

Code: Select all

?>
<INPUT TYPE=hidden NAME="TaskDescription" VALUE="<? echo($TaskDescription);?>">


Jay

Re: escape quotes

Post by Jay » Tue Aug 20, 2002 2:57 am

WiZARD wrote:try this:

Code: Select all

?>
<INPUT TYPE=hidden NAME="TaskDescription" VALUE="<? echo($TaskDescription);?>">


That doesn't address the original problem.

Even so, it's far neater to write
<input type=hidden name="TaskDescription" value="<?=$TaskDescription?>">
:)

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests