| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Apr 2004
12 posts
Gave thanks: 0
Thanked 0 times
|
Hi,
I'm trying to enter some data into MySQL, but I keep getting this error: PHP Code:
PHP Code:
|
|
|
|
|
|
#2 (permalink) |
|
I admire kayla
On a golden path...
Joined in Aug 2003
Lives in Saint Petersburg, Florida
Hosted on VPS5
478 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
|
NEVERmnd
__________________
“The object of war is not to die for your country, but to make some other bastard die for his.” -George Patton VPS5 Last edited by Unleashed2k; September 9th, 2004 at 12:47 AM. |
|
|
|
|
|
#3 (permalink) |
|
Surpass Fan
Comfy Contributor
Joined in Apr 2004
Lives in Canada
Hosted on Pipe
141 posts
Gave thanks: 4
Thanked 3 times
|
PHP Code:
Tell me if it works ! |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Apr 2004
12 posts
Gave thanks: 0
Thanked 0 times
|
Thanks for the suggestion MadMax, but I still get the error even after I put in the quotes.
I've changed weight and case to prod_weigh and prod_cas also, but that still gave me the same error. I thought series and name may also be reserved names, so i changed them to prod_nam and prod_s. So, my query looks like this PHP Code:
PHP Code:
Error in query: INSERT INTO product ('stock_num', 'prod_s', 'prod_nam', 'thread_id', 'dim_h', 'dim_w', 'dim_l', 'prod_weigh', 'prod_cas') VALUES ('10175', 's1a', 'frikken plabe', '325', '12.4', '123', '21', '12.6', '4'). 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 ''stock_num', 'prod_s', 'prod_nam', 'thread_id', 'dim_h', 'dim_w I do't get it, it looks right to me, no matter how i look at it. Please help! Thanks! Chap |
|
|
|
|
|
#5 (permalink) |
|
Web Hosting Super Ninj4
Super #1
Joined in Sep 2003
Lives in Fullerton, CA
1,581 posts
Gave thanks: 0
Thanked 2 times
|
Try removing the quotes in the first group, and removing the spaces between the commas.
On the next group, have single quotes and no spaces between the commas. I've seen some cases where MySQL can be very picky of these things. |
|
|
|
|
|
#6 (permalink) |
|
Surpass Fan
Seasoned Poster
Joined in Aug 2004
Lives in North Carolina, USA
Hosted on Pass11
46 posts
Gave thanks: 0
Thanked 0 times
|
Use backticks ` around table and field names.
Use single quotes ' around values.
__________________
All your base are belong to us. |
|
|
|
|
|
#8 (permalink) |
|
Registered User
Seasoned Poster
Joined in Aug 2004
84 posts
Gave thanks: 0
Thanked 0 times
|
This SHOULD work, you don't need ' or ` unless the names have spaces or wierd charactors, so you should always use the for WHAt you insert of course because you don't always know what it will be in DB systems:
PHP Code:
Last edited by Scribe; September 10th, 2004 at 12:23 PM. |
|
|
|
|
|
#9 (permalink) |
|
Surpass Fan
Seasoned Poster
Joined in Aug 2004
Lives in North Carolina, USA
Hosted on Pass11
46 posts
Gave thanks: 0
Thanked 0 times
|
According to PHP.net, the querystring should not end with a semicolon.
http://us4.php.net/mysql_query Backticks are optional around table/field names (since he changed the field names to nonreserved words) but they won't hurt anything. Single Quotes around values are a must though (except on numeric values, but it's still ok to use them).
__________________
All your base are belong to us. |
|
|
|