Forums

PHP

This topic is locked

insert problem with special characters

Posted 26 Oct 2001 10:57:52
1
has voted
26 Oct 2001 10:57:52 philippe lê posted:
Hi,
I made an insert page that works fine except when I want to insert data that contains the ' character I get an error.
For exemple inserting "my friend's house" doesn't work.
Does anyone know how to solve that ?

Replies

Replied 26 Oct 2001 11:59:11
26 Oct 2001 11:59:11 Bruno Mairlot replied:
You've got two solutions :

1. Modify the entered value to replace all the ' with something like \' or '' depending on what it is for.

2. Let PHP do it for you. There is a php.ini configuration, that will set PHP engine to treat all forms input before releasing them to the script. Therefore all ' character will automatically be replaced with \'

The config is : <b>magic_quotes_gpc = On</b>

But you have three magic quotes possibility, here is the content of my php.ini :

; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = On

; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off

; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off

If you don't have access to your php.ini, then there is always a possibility to change some variables on-the-fly ! Though, I don't remember. Rawveg posted the function in other thread.

Make a search on magic_quotes in the text forum, you should find the thread talking about this issue.

Hope it helps,

Bruno


--- Better to die trying, than never try at all ---
Replied 26 Oct 2001 12:21:17
26 Oct 2001 12:21:17 philippe lê replied:
I did what you said and IT WORKED !!
Thank you very much for the tip.

Reply to this topic