Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

PHP-MySQL-HTML - handling double quote in data

db field needs to have a measurement inserted



12:10 pm on Nov 24, 2009 (gmt 0)

5+ Year Member

I cannot get the quote to appear in the field variable for the MySQL query. Below are the relevant parts -- help much appreciated. No crashing hurry, I'm just trying to avoid having to use PHPmyadmin! I've tried many things here, none of which work, and the following is one version, just to outline what I'm trying to do.

HTML form option code for dropdown list on 'size':
<option value="1-5/8"">1-5/8"</option>

PHP functions on variable:
$goodsize = stripslashes($_POST['size']);
print "$goodsize ";
$fgoodsize = mysql_real_escape_string($goodsize);
print "$fgoodsize";

print results: 1-5/8 1-5/8 (no quote shows up)

MySQL line:
$query = "INSERT INTO buttons
('id', 'artist', 'button_name', 'size',' price', 'sold', 'where_sold', 'date', 'image_file', 'page')
VALUES (0, '{$_POST['artist']}',
'$fgoodsize', // field in question is here

Could not add the entry because: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''id', 'artist', 'button_name', 'size',' price', 'sold', 'where_sold', 'date', 'i' at line 2. The query was INSERT INTO buttons ('id', 'artist', 'button_name', 'size',' price', 'sold', 'where_sold', 'date', 'image_file', 'page') VALUES (0, 'CD', 'Test Button', '1-5/8', '6', '0', '', NOW(), 'cd-test-form.jpg', 'green.htm').

Again, thanks for any ideas! (Of course I'm not entirely sure the query is right anyway (with or without the quote!) lol.



6:02 pm on Nov 24, 2009 (gmt 0)

5+ Year Member

ignore this topic/post -- solved problem




Featured Threads

Hot Threads This Week

Hot Threads This Month