inserting free-form text with quotes to mysql

From: Date: Fri, 20 Jul 2001 18:57:17 +0000
Subject: inserting free-form text with quotes to mysql
Groups: php.general 
Request: Send a blank email to php-general+get-58956@lists.php.net to get a copy of this message
I'm creating a specialized "suggestion box" type of web application in PHP. I'm using MySQL for data storage. Whenever I try to submit text that contains a double quote character ("), the submission gets truncated at the first occurance of a double quote and beyond. Single quotes don't seem to be problematic. So if the user inputted the following text: hello " my suggestion for deals with improving the... then only "hello" would get put in the database, and everything from the double quote to the end of the input would be truncated. I've tried addslashes() and removeslashes() before the submit, but that doesn't seem to help. The input data actually gets POST'ed twice: once when the user submits his form. After he submits, I bring up a "verification" form, where I show what the user submitted so he can check to make sure everything is accurate. From the verification page, I call another php page to actually do the database writing. (Note, when I played with add/removeslashes(), I was doing so on the last php page, i.e., where the database operation actually takes place). I've noticed that either PHP, my browser, or the webserver seem to add slashes automatically because any quotes (single or double) or slashes are escaped with a slash on the verification page. Hopefully this is just something simple I'm overlooking :) Thanks, Matt

« previous php.general (#58956) next »