Automatic Addslashes

Started by Enrico Cominiover 25 years ago2 messagesgeneral
Jump to latest
#1Enrico Comini
algobit@algobit.com

I do

copy tmp from '/home/algobit/product.txt

tmp ia a table with one record (line varchar(255))

in product.txt I have many line as:

2;"100";"Parmigiano Reggiano";"Parmigiano Reggiano stagionato 2
anni";4;"parmigiano4.jpg";2;"Fette 1 Kg";0.18;1;1.00;"true"

Then with "select * from tmp" the result is exactly like in the original
file

2;"100";"Parmigiano Reggiano";"Parmigiano Reggiano stagionato 2
anni";4;"parmigiano4.jpg";2;"Fette 1 Kg";0.18;1;1.00;"true"

But when i fetch in a variable the rercords (with php) i READ in the
variable

2;\"100\";\"Parmigiano Reggiano\";\"Parmigiano Reggiano stagionato 2
anni\";4;\"parmigiano4.jpg\";2;\"Fette 1 Kg\";0.18;1;1.00;\"true\"

the question is : The SLASH are effectively in the record ?

#2GH
grasshacker@over-yonder.net
In reply to: Enrico Comini (#1)
Re: Automatic Addslashes

On Fri, Nov 24, 2000 at 01:29:41PM +0100, some SMTP stream spewed forth:

I do

copy tmp from '/home/algobit/product.txt

tmp ia a table with one record (line varchar(255))

in product.txt I have many line as:

2;"100";"Parmigiano Reggiano";"Parmigiano Reggiano stagionato 2
anni";4;"parmigiano4.jpg";2;"Fette 1 Kg";0.18;1;1.00;"true"

Then with "select * from tmp" the result is exactly like in the original
file

2;"100";"Parmigiano Reggiano";"Parmigiano Reggiano stagionato 2
anni";4;"parmigiano4.jpg";2;"Fette 1 Kg";0.18;1;1.00;"true"

But when i fetch in a variable the rercords (with php) i READ in the
variable

2;\"100\";\"Parmigiano Reggiano\";\"Parmigiano Reggiano stagionato 2
anni\";4;\"parmigiano4.jpg\";2;\"Fette 1 Kg\";0.18;1;1.00;\"true\"

the question is : The SLASH are effectively in the record ?

Not if, as you say, a regular non-php select returns the "original"
record. Likely, your PHP setup has magic_quotes_runtime (or
magic_quotes_gpc) set to On. This would cause PHP to "addslashes()" to
the data gathered from the db (also true for forms, etc).

Make sense?

You can use get_magic_quotes_runtime or get_magic_quotes_gpc to retrieve
the current setting of the two options.

http://www.php.net/manual/configuration.php#ini.magic-quotes-gpc
gives a nice summary.

cheers.

gh

Show quoted text