Forum Moderators: coopster

Message Too Old, No Replies

How to get strings containig the char ' into mysql?

         

Garfield

10:47 pm on Apr 9, 2004 (gmt 0)

10+ Year Member



Hi,

I'm having roblems with saving texts containing the char ' (like in O'Brien) into mysql. Since PHP seems to recognize this character as string delimiter, it doesn't work.

How can I get around this? Do I have to escape all ' chars like this: \'? Or is there a better way of getting them saved into mysql?

Thanks in advance!

kniceguy2know

10:55 pm on Apr 9, 2004 (gmt 0)

10+ Year Member



Check out the addslashes() function in php. I think it'll serve your purpose quite well. Tell me if it works out.

willybfriendly

10:56 pm on Apr 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



addslashes() or mysql_escape()

WBF

Garfield

12:40 pm on Apr 10, 2004 (gmt 0)

10+ Year Member



I used the mysql_escape_string function and now everything works properly.

Thanks

Sarvesh Nagpal

3:58 pm on Apr 10, 2004 (gmt 0)

10+ Year Member



Any suggestions if we have to deal with same problem in language PERL?

coopster

9:47 pm on Apr 12, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If you are using the DBI Module you can quote [cpan.uwinnipeg.ca] 'em.

Sarvesh Nagpal

3:39 pm on Apr 23, 2004 (gmt 0)

10+ Year Member



Thanks coopster! It works great.