gordon.c Posted April 14, 2009 Share Posted April 14, 2009 Hello, I am having troubles with ' character. It seems mysql has some problems with this character and I cant get a text containing this char to be saved in the database, it does not process the query to inseft. Any hints what to do here? Shall I somehow try to exchange this character with similar looking apostrophes? Thank you Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/ Share on other sites More sharing options...
Mchl Posted April 14, 2009 Share Posted April 14, 2009 mysql_real_escape_string Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-809813 Share on other sites More sharing options...
wildteen88 Posted April 14, 2009 Share Posted April 14, 2009 You need to escape quotes within strings before it goes into the database. Use mysql_real_escape_string to escape such characters (and any other harmful characters) when inserting data into the database Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-809817 Share on other sites More sharing options...
.josh Posted April 14, 2009 Share Posted April 14, 2009 $string = preg_replace('~[\'"]~,"",$string); I promise, SQL will no longer complain about the quotes. Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-809822 Share on other sites More sharing options...
gordon.c Posted April 20, 2009 Author Share Posted April 20, 2009 $string = preg_replace('~[\'"]~,"",$string); I promise, SQL will no longer complain about the quotes. Thank you works very well Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-814626 Share on other sites More sharing options...
.josh Posted April 20, 2009 Share Posted April 20, 2009 hahaha noooo dude that was a joke - mysql won't complain about the quotes from that because it removes all of the quotes! Use mysql_real_escape_string like what was already suggested. Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-814636 Share on other sites More sharing options...
Daniel0 Posted April 20, 2009 Share Posted April 20, 2009 Dude, learn AT LEAST the basic syntax before trying. INSERT INTO foo (bar) VALUES ('It's not working'); Do you think it can distinguish between your ' and its '? Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-814659 Share on other sites More sharing options...
.josh Posted April 20, 2009 Share Posted April 20, 2009 How are computers going to possibly become our future overlords, if they can't at the very least, know the difference? pfft. I wag my ass at our future overlords. Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-814665 Share on other sites More sharing options...
Mchl Posted April 20, 2009 Share Posted April 20, 2009 How are computers going to possibly become our future overlords, if they can't at the very least, know the difference? pfft. I wag my ass at our future overlords. They'll have magic_quotes enabled obviously. Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-814668 Share on other sites More sharing options...
premiso Posted April 20, 2009 Share Posted April 20, 2009 I thought the Zombies would take care of that...I mean if they take over the world the computing part would be "automated" by mindless people poking keys....oh wait...that already happens. The computers have turned us into Zombies...FAIL! The overlords have won. Link to comment https://forums.phpfreaks.com/topic/154055-solved-get-rid-of-char/#findComment-814673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.