Re: Single quotes in INSERT statements?

From: Date: Tue, 25 Apr 2006 19:08:57 +0000
Subject: Re: Single quotes in INSERT statements?
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-41743@lists.php.net to get a copy of this message
Skip Evans wrote:
I was under the impression that addslashes() would handle single quote marks in INSERT statements, but when I execute the following: $sql="UPDATE images SET orderno=$orderno, url='".addslashes($url)."', banner=$banner,caption='".addslashes($caption)."' WHERE imageID=$imageID"; ...and $caption contains something like: "Don't look" ...the data is chopped off at the single quote mark. How, if not addslashes(), does one handle this?
Change the contents of $sql to use double quotes around the strings instead of single - that's what real_escape_string was designed to escape. Alternatively use str_replace to escape single quotes. -Stut

« previous php.db (#41743) next »