homepage Welcome to WebmasterWorld Guest from 54.198.94.76
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
PHP-MySQL-HTML - handling double quote in data
db field needs to have a measurement inserted
Clair




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

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']}',
'{$_POST['button_name']}',
'$fgoodsize', // field in question is here
'{$_POST['price']}',
'{$_POST['sold']}',
'{$_POST['where_sold']}',
NOW(),
'{$_POST['image_file']}',
'{$_POST['page']}')";

ERROR MSG:
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.

Clair

 

Clair




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

ignore this topic/post -- solved problem

Thanks!

Clair

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved