[FX.php List] Displaying & Updating comments
AC
ac at pottnerconsulting.ca
Thu Jul 20 10:49:10 MDT 2006
The problem was that a user could put any HTML tags, not just <B> into
the comment field.
I had a look through the PHP manual for ideas on which commands I could
use to get the data formated correctly.
As far as I can tell I now have it working using;
echo('JSComment' . $TheRecID . "='" . str_replace("\n", "<BR>'\n+ '",
htmlentities(addslashes($ResultOne['Comment'][0]))) . "';\r\n");
I needed to use / display the comment in 3 different places so I loaded
it into a javascript variable and then use document.write to display
the text.
Thanks for the suggestion though.
On Jul 19, 2006, at 3:21 PM, Joel Shapiro wrote:
> Hi AC
>
> What about if you add in "</B>" (without quotes) after the Comment
> field, as such:
>
> <? echo('<P><FONT SIZE="+1">' . $ResultOne['Comment'][0] .
> '</B></FONT></P>' . "\r\n"); ?>
>
> I haven't tried this, but I'm thinking that this way you would be
> ending whatever bold command has been added within the comment. I
> would think that a stray </B> won't break anything if there's no
> starting <B> (even though it might not be the 'cleanest' thing to do).
>
> HTH
> -Joel
>
>
> Joel Shapiro - FileMaker Pro Database Design
> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
> joelshapiro at jsfmp dot com
> http://www.jsfmp.com
> 415-269-5055
>
>
> On Jul 18, 2006, at 10:29 AM, AC wrote:
>
>> Sorry if this screws something up, I had to copy it from the website
>> and then e-mail it.
>>
>> I'm not sure what you mean by "Real the sample that is in FX.zip?"
>> If you're asking if I can update regular text fields the answer is
>> yes.
>> Am I using the latest copy of FX, yes.
>> Are you saying there's a sample file in the FX folder that shows how
>> to display & update a comment field that may contain HTML code, if so
>> could you tell which file specifically?
>> If you're suggesting that I should read the documentation that came
>> with FX, I have.
>>
>> Just to clarify my problem, when I use the command
>> <? echo('<P><FONT SIZE="+1">' . $ResultOne['Comment'][0] .
>> '</FONT></P>' . "\r\n"); ?>
>> and the comment includes text like "<B>" it turns all text after it
>> to bold.
>>
>> I used the htmlentities() & str_replace() which fixed the problem for
>> display purposes, however I can't seem to get this to work for
>> updating records.
>> If the user types
>> a'a"a\a
>> into the comment field, then the database will contain the text
>> a\'a\"a\\a
>>
>> I tried using
>> $Search->AddDBParam('Comment', str_replace('\\\\', '\\',
>> str_replace('\"', '"', str_replace("\'", "'",
>> $_REQUEST['Comment']))));
>> which works unless a user uses the funny single or double quotes. I
>> assume there's an easier way to do this and I was hoping someone
>> could point me in the right direction.
>>
>>
>>
>>
>>
>> ggt667 at gmail.com wrote:
>> Real the sample that is in FX.zip?
>>
>> ggt667
>>
>> On 7/18/06, AC <ac at pottnerconsulting.ca> wrote:
>> > I'm fairly new to FX, PHP and HTML.
>> > I need to do the following with a comments field;
>> > - display it on the web
>> > - pass it as a hidden value to be entered into the database
>> > - pre-populate a textarea with it again to be put into the
>> database
>> >
>> > If I just display the comments then text like" <B>" makes the rest
>> of
>> > the characters that follow bold.
>> > I tried htmlentities() which worked but gave me "”" instead of
>> a
>> > quote.
>> > Now I'm using str_replace() to substitute the text "”" back
>> to a
>> > quote.
>> > My problem with this is it still doesn't cover things like multiple
>> > spaces and carriage returns.
>> > I also have issues when a user enters weird quotes, I can't seem to
>> > write those to the database at all.
>> >
>> > How should I be doing
>> this?_______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
___________________________________________
Pottner Consulting
(613) 673-8866
http://www.pottnerconsulting.ca
More information about the FX.php_List
mailing list