Jump to content

Apostrophes Ugh


awiiya

Recommended Posts

So I've been having some issues with the displaying qualities. I'm fairly certain the issue is the html and css of MD rather than php, but here is a watered down version of what I'm having issues with:

html side
[code]
<form method="post" action="">
<textarea rows="20" cols="30" name="ApoProbs">
Add apostrophes or quotes in this box!!
</textarea>
<input type="submit" value="Submit!">
</form>
<--! content separator -->
<style type="text/css">
//This CSS is used to ensure that the pre will have wordwrap, rather than extending all the way off the page.
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
<pre>
[[APOTESTS]]
</pre>
[/code]

This in the MDS side
[code]
if (isset(@input['ApoProbs']))
echo str_replace("[[APOTESTS]]", @input['AproProbs'], @content[1]);
else
echo @content[0];
[/code]

If you enter any apostrophes or double quotes in the textarea, they appear with backslashes when outputted. In the debug, however, there don't appear to be backslashes stored in the array. Strange!

[b]SOLUTION[/b]

It seems that even though the debug wasn't showing it, there were in fact backslashes being stored, which means that php automatically escapes ' and " when they are entered into the input. The solution is very simple:

[code]
if (isset(@input['ApoProbs'])){
@vt = stripslashes(@input['ApoProbs']);
echo str_replace("[[APOTESTS]]", @vt, @content[1]);
}
else
echo @content[0];
[/code]

Thank you.

Awi

Edited by awiiya
Link to comment
Share on other sites

  • Root Admin

Apart from your code having multiple errors each rather basic.

I see nothing wrong as you described on yim.

I believe the issues you are having, is with the storages and such. Perhaps you can explain the issue better?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Forum Statistics

    17.5k
    Total Topics
    182.5k
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...