![]() |
|
[PHP] Single quotes being escaped - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [PHP] Single quotes being escaped (/showthread.php?tid=4146229) |
Single quotes being escaped - michael1026 - Mar 31, 2014 So I'm inserting content into a mysqli database, but when I do, it's escaping single quotes, even though nothing in my code is making it do that. Does PDO do this automatically or something? How can I fix it? It needs to be echoed out to a page. Edit: to commentate for this, I'm using stripslashes(), but any explanation why it's doing this in the first place? * - La Manifesto - Mar 31, 2014 (Mar 31, 2014 09:43 PM)michael1026 Wrote: So I'm inserting content into a mysqli database, but when I do, it's escaping single quotes, even though nothing in my code is making it do that. Does PDO do this automatically or something? How can I fix it? It needs to be echoed out to a page. Try to insert content without using stripslashes(). * - michael1026 - Mar 31, 2014 (Mar 31, 2014 10:02 PM)Yani Wrote: Wait, are you using mysqli or PDO?PDO, sorry for the confusion. I don't have much code.... PHP Code I think it may be my host that's doing it automatically. (Mar 31, 2014 09:56 PM)Adherence Wrote: Try to insert content without using stripslashes(). I have. I used stripslashes after I found out that it was doing this to remove them. * - La Manifesto - Mar 31, 2014 (Mar 31, 2014 10:11 PM)michael1026 Wrote: PDO, sorry for the confusion. I don't have much code.... You could always try addslashes(), it might work. * - michael1026 - Mar 31, 2014 (Mar 31, 2014 10:13 PM)Adherence Wrote: You could always try addslashes(), it might work. Well, right now stripslashes is working. I was just curious why this was happening in the first place. I'm just going to assume that it's the host that does it automatically. * - La Manifesto - Mar 31, 2014 (Mar 31, 2014 10:24 PM)michael1026 Wrote: Well, right now stripslashes is working. I was just curious why this was happening in the first place. I'm just going to assume that it's the host that does it automatically. Oh I wasn't clear on that. I assume it doesn't work because PDO automatically removes stuff like that when you bind them. * - themastersinner - Apr 1, 2014 Sounds like you have magic_quotes turned on. http://www.php.net/manual/en/security.magicquotes.what.php http://en.wikipedia.org/wiki/Magic_quotes |