Re: adding "addslahses" to already live project - best approach?
From: Brent Palmer (bapalmer_at_bigpond.net.au)
Date: 03/21/05
- Next message: Geoff Berrow: "Re: problem with this age validator - workarounds?"
- Previous message: Geoff Berrow: "Re: String comparison problem..."
- In reply to: Dave Smithz: "adding "addslahses" to already live project - best approach?"
- Next in thread: Brion Vibber: "Re: adding "addslahses" to already live project - best approach?"
- Reply: Brion Vibber: "Re: adding "addslahses" to already live project - best approach?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 21 Mar 2005 07:34:55 GMT
"Dave Smithz" <SPAM FREE WORLD> wrote in message
news:423e2152$1@news1.homechoice.co.uk...
> Having adopted someone else's PHP cope and completing a crash course in
> the
> language I came across a (probably common) problem with the current code.
>
> On a registration form, whenever users names have an apostrophe in them it
> causes problems as they do not get added to the DB correctly for reasons
> that immediately become apparent.
>
> Before implementing my own workaround I noticed the functions.
>
> addslashes, stripslashes and directive magic_quotes_gpc. These seem like
> great ideas and I will now use them.
>
> What is the best way of introducing this practise across all of the code
> for
> this project. It is something I want to progressively, therefore as I make
> changes when necessary, I will also add these changes, I do not want to
> have to go through the entire code now changing everything.
>
> Can I just do something like the following
>
> On each new script I create do the following.
>
> Check if the magic quotes directive is enabled, and if so do nothing, but
> if
> not, manually run the addslashes function and wherever data is retrieved
> from the database go in and add a stripslashes.
>
> Actually I could just make the changes in the code that writes to and
> retrieves info from the database rather then on each script that collects
> form input. This would therefore lessen the need to make multiple changes
> to
> the code.
>
> Is that all I will need to do. Is there any implications that I am not
> aware
> of by implementing this in a particular way?
>
> Forgive the slight vagueness in this question, I am still surprised to
> find
> this was not done in the start.
>
> Kind regards
>
> Dave
I agree with Brian but I use the function htmlspecialchars();
This changes the special chars like quotes ' and " and so on... to HTML
entities .
Eg.
'&' (ampersand) becomes '&'
'"' (double quote) becomes '"' when ENT_NOQUOTES is not set.
''' (single quote) becomes ''' only when ENT_QUOTES is set.
http://au2.php.net/htmlspecialchars
Brent Palmer.
- Next message: Geoff Berrow: "Re: problem with this age validator - workarounds?"
- Previous message: Geoff Berrow: "Re: String comparison problem..."
- In reply to: Dave Smithz: "adding "addslahses" to already live project - best approach?"
- Next in thread: Brion Vibber: "Re: adding "addslahses" to already live project - best approach?"
- Reply: Brion Vibber: "Re: adding "addslahses" to already live project - best approach?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|