Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 why HTMLEncode in chkString(SQLString)?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

bjlt
Senior Member

1144 Posts

Posted - 05 December 2002 :  12:50:13  Show Profile
in function chkString(pString,fField_Type) there's Case "archive" and Case "SQLString" I think these two should be identical as they are input strings to the database. in "SQLString" there's
fString = HTMLEncode(fString)
while in "archive" there's not

first I can't figure out why fString = HTMLEncode(fString) is needed, second if it's needed, don't we also need it in "archive"?

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 05 December 2002 :  13:02:33  Show Profile  Visit HuwR's Homepage
when you are archiving, the data has come directly from the db so there is no need to do the etra steps, where as the "SQLString" fieldtype is for dealing with entered text from the browser.
Go to Top of Page

bjlt
Senior Member

1144 Posts

Posted - 05 December 2002 :  13:05:42  Show Profile
ah i see. thanks.
I'm afraid I still don't know why we need HTMLEncode?
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 05 December 2002 :  13:09:10  Show Profile  Visit HuwR's Homepage
try it without, you will soon find out
Go to Top of Page

David K
Junior Member

494 Posts

Posted - 05 December 2002 :  13:20:20  Show Profile  Send David K an AOL message  Send David K an ICQ Message  Send David K a Yahoo! Message
htmlencode prvents the use of html tags in the code, and it sets it so that you'll be able to see the actual code when a uses post something with html, for example
<html>
</html>
Go to Top of Page

bjlt
Senior Member

1144 Posts

Posted - 06 December 2002 :  02:53:13  Show Profile
Thanks, I know what HTMLEncode does.

my question is, why do we need it in Case SQLString.

I see in other cases it is

if strAllowHTML <> "1" then
fString = HTMLEncode(fString)
end if

but in case SQLString it's just
fString = HTMLEncode(fString).


Is it true that we don't need HTMLEncode data to be entered to the database, if it's not to be shown on webpages or we will allow html tags. then I can't use chkString("",SQLString) on non-forum codes or I need one with the HTMLEncode line removed?

maybe a guide to function chkString is helpful.




Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 06 December 2002 :  04:08:29  Show Profile  Visit HuwR's Homepage
I have no idea what you mean
Go to Top of Page

bjlt
Senior Member

1144 Posts

Posted - 06 December 2002 :  07:52:59  Show Profile
I meant chkString("",SQLString) is designed for snitz as it uses fString = HTMLEncode(fString). generally we don't need fuctions like HTMLEncode for data to be entered into the database, right?

then why in other cases in chkString, it's
if strAllowHTML <> "1" then
fString = HTMLEncode(fString)
end if

why in SQLstring we don't need to check if strAllowHTML = 1?

with all other types (cases) in chkString, for what reason we need
HTMLEncode(fString) in case SQLstring?
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 06 December 2002 :  08:00:22  Show Profile  Visit HuwR's Homepage
why don't you try removing it and see, this has always been in the code since i started working with it, so I have no idea why it was originally added
Go to Top of Page

David K
Junior Member

494 Posts

Posted - 06 December 2002 :  08:27:39  Show Profile  Send David K an AOL message  Send David K an ICQ Message  Send David K a Yahoo! Message
some functions (mostly admin ones) remove the HTML code when saving and not when displaing, to save resources, I would reccvommend you to make a new parameter for chkstring, and make it do what you want, and when you need to use it and not the normal SQLString, use the one you made!
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 06 December 2002 :  08:28:10  Show Profile
It's done the way it's done so that data already in the database won't need to be changed if the admin changes whether HTML is turned on or off. Basically we store the data in the database the same whether HTML is turned on or off.
Go to Top of Page

David K
Junior Member

494 Posts

Posted - 07 December 2002 :  15:23:51  Show Profile  Send David K an AOL message  Send David K an ICQ Message  Send David K a Yahoo! Message
exactly, it's safer to save html in an encoded format and later decode it if HTML is allowed, then to encode it when loading (should be much faster as well)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.21 seconds. Powered By: Snitz Forums 2000 Version 3.4.07