|
Posted by ByteCoder on 09/27/90 11:37
Oli Filth <catch@olifilth.co.uk> wrote in
news:%BLyf.35809$W4.22578@newsfe4-gui.ntli.net:
> ByteCoder said the following on 16/01/2006 10:40:
>> Is it possible to change the value in a resultset?
>
> No.
>
> <...SNIP CODE...>
>
>> I want to do this because I don't want the writer of a web page to
>> have to bother about stripslashes() and the like. In that scenario
>> the writer of the web page would execute a function to get the
>> contents of a table. I would then get the result, do a stripslashes
>> on the columns that need it, reset the pointer to the first row and
>> then return the result.
>
> Put the processed results into a temporary array, and then return that
> array. e.g.:
>
> <?php
> $processedResults = array();
> while($row = mysql_fetch_array($result))
> {
> /* process row here */
> $row['username'] = stripslashes($row['username']);
>
> $processedResults[] = $row;
> }
>
> /* $processedResults now holds all processed rows */
>
> ?>
>
>
> Incidentally, why are you storing stuff in your databases in a way
> that requires stripslashes() to be called? Just store the raw text,
> don't apply addslashes() or whatever to it.
>
>
Thanks for the awnser. I do the addslashes and stripslashes because I
want to prevent SQL injection attacks. (When inserting a value in a DB
that was entered by a visitor). The user table was just an example.
--
----------------------------------
- ByteCoder -
- "Da Evul Dootchie" -
- Qnl0ZUNvZGVyQHBsYW5ldC5ubA== -
----------------------------------
Navigation:
[Reply to this message]
|