pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: insert a special character
4+ messages / 4 participants
[nested] [flat]
* Re: insert a special character
@ 2002-03-28 05:15 Christopher Kings-Lynne <chriskl@familyhealth.com.au>
parent: arun kv <arun@library.iisc.ernet.in>
1 sibling, 0 replies; 4+ messages in thread
From: Christopher Kings-Lynne @ 2002-03-28 05:15 UTC (permalink / raw)
To: arun kv <arun@library.iisc.ernet.in>; pgsql-php
You need to go:
addSlashes($strexp) on the string before inserting it.
This will replace all 's and "s with \' and \"
You open up a massive security hole in your database if you're not
addSlashing every value that goes in...
Chris
> -----Original Message-----
> From: pgsql-php-owner@postgresql.org
> [mailto:pgsql-php-owner@postgresql.org]On Behalf Of arun kv
> Sent: Thursday, 28 March 2002 1:19 PM
> To: PGSQL
> Subject: [PHP] insert a special character
>
>
> hello,
> I have a string with ' this symbol in the middle of the text
> example:-
> " that book belong to rahul's sister"
>
> this string is to be stored in the variable "$strexp"
> when I am inserting this variable in database table
> following error apperes
>
>
> " parse error at or near "s" "
>
> How can I read the string and store in a variable and insert the same
> into the database table ?
>
> thanks in advance ,
> with regards,
> Arun
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: insert a special character
@ 2002-03-28 05:16 Chris <csmith@squiz.net>
0 siblings, 0 replies; 4+ messages in thread
From: Chris @ 2002-03-28 05:16 UTC (permalink / raw)
To: arun kv <arun@library.iisc.ernet.in>; pgsql-php
Hi,
> I have a string with ' this symbol in the middle of the text
> example:-
> " that book belong to rahul's sister"
>
> this string is to be stored in the variable "$strexp"
> when I am inserting this variable in database table
> following error apperes
>
>
> " parse error at or near "s" "
>
> How can I read the string and store in a variable and insert the same
>into the database table ?
Use the addslashes function.
Basically:
$newstring = addslashes($oldstring);
or
$newstring = addslashes("this is some sampl''e text''");
See http://www.php.net/addslashes for more details.
Then, when you get it out of the database you need to stripslash the
string. (Does the above in reverse).
HTH,
-----------------
Chris Smith
http://www.squiz.net/
^ permalink raw reply [nested|flat] 4+ messages in thread
* insert a special character
@ 2002-03-28 05:18 arun kv <arun@library.iisc.ernet.in>
0 siblings, 2 replies; 4+ messages in thread
From: arun kv @ 2002-03-28 05:18 UTC (permalink / raw)
To: pgsql-php
hello,
I have a string with ' this symbol in the middle of the text
example:-
" that book belong to rahul's sister"
this string is to be stored in the variable "$strexp"
when I am inserting this variable in database table
following error apperes
" parse error at or near "s" "
How can I read the string and store in a variable and insert the same
into the database table ?
thanks in advance ,
with regards,
Arun
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: insert a special character
@ 2002-03-28 05:46 PG Explorer <pgmail@pgexplorer.com>
parent: arun kv <arun@library.iisc.ernet.in>
1 sibling, 0 replies; 4+ messages in thread
From: PG Explorer @ 2002-03-28 05:46 UTC (permalink / raw)
To: arun kv <arun@library.iisc.ernet.in>; pgsql-php
Swich Magic Quotes On
http://www.pgexplorer.com
PosgtreSQL Frontend Client
----- Original Message -----
From: "arun kv" <arun@library.iisc.ernet.in>
To: "PGSQL" <pgsql-php@postgresql.org>
Sent: Thursday, March 28, 2002 7:18 AM
Subject: [PHP] insert a special character
> hello,
> I have a string with ' this symbol in the middle of the text
> example:-
> " that book belong to rahul's sister"
>
> this string is to be stored in the variable "$strexp"
> when I am inserting this variable in database table
> following error apperes
>
>
> " parse error at or near "s" "
>
> How can I read the string and store in a variable and insert the same
> into the database table ?
>
> thanks in advance ,
> with regards,
> Arun
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-03-28 05:46 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-28 05:16 Re: insert a special character Chris <csmith@squiz.net>
2002-03-28 05:18 insert a special character arun kv <arun@library.iisc.ernet.in>
2002-03-28 05:15 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
2002-03-28 05:46 ` PG Explorer <pgmail@pgexplorer.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox