Mar 31, 2014 09:43 PM
(This post was last modified: Mar 31, 2014 09:48 PM by michael1026.)
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?
Account Cracking | Website Pentesting
(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.
Edit: to commentate for this, I'm using stripslashes(), but any explanation why it's doing this in the first place?
Try to insert content without using stripslashes().
Mar 31, 2014 10:11 PM
(This post was last modified: Mar 31, 2014 10:12 PM by michael1026.)
(Mar 31, 2014 10:02 PM)Yani Wrote: Wait, are you using mysqli or PDO?
Also, showing your code would actually be better. PDO, sorry for the confusion. I don't have much code....
PHP Code
<?php $content = $_POST['topic_content']; $stmt = $dbh->prepare("INSERT INTO posts (post_content) VALUES (:content)"); $stmt->bindParam(':content', $content); $stmt->execute();
I think it may be my host that's doing it automatically.
(Mar 31, 2014 09:56 PM)La Manifesto 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.
Account Cracking | Website Pentesting
(Mar 31, 2014 10:11 PM)michael1026 Wrote: PDO, sorry for the confusion. I don't have much code....
PHP Code
<?php $content = $_POST['topic_content']; $stmt = $dbh->prepare("INSERT INTO posts (post_content) VALUES (:content)"); $stmt->bindParam(':content', $content); $stmt->execute();
I think it may be my host that's doing it automatically.
I have. I used stripslashes after I found out that it was doing this to remove them.
You could always try addslashes(), it might work.
(Mar 31, 2014 10:13 PM)La Manifesto 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.
Account Cracking | Website Pentesting
(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.
|