Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-30-2012, 04:13 PM   PM User | #1
KristyFord
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
KristyFord is an unknown quantity at this point
Unknown column 'FirstName' in 'field list'

I'm new to PHP and MYSQL. I am struggling with an error - Unknown column 'FirstName' in 'field list'. I have a form that I want to add the fields into a new table tbl_refrigerated_wine_cabinet_request. I've verified the spelling of the column names in the new table. Following is a snippet of the code. Thanks for your help!

[CODE]
$refrigerated_wine_cabinet_request_table = 'tbl_refrigerated_wine_cabinet_request';

if ($_POST) {

$mysql_data = " (FirstName, LastName, Email, Phone, ContactPreference, CabinetType, CabinetQty, Cabinet1HandleLocation, Cabinet2HandleLocation, Cabinet3HandleLocation, Cabinet4HandleLocation, BuiltIn, FinishedEnds, Size, Shelves, HardwareStyle, CabinetFinish, HardwareColor, LEDQty, CenterEtchingQty, BorderEtchingQty, ArchedDoorEtchingQty, WoodSpecies, Stain, Other, UserAgent, IPAddress, HTTPReferer, TimeStamp, EmailOptIn )
VALUES
('$first_name', '$last_name', '$email', '$phone', '$contactpref', '$cabinet_type','$cabinet_quanitity', '$handle_location1', '$handle_location2', '$handle_location3', '$handle_location4', '$built', '$finished_ends' , '$size', '$shelves', '$hardware_style', '$finish', '$hardware_color', '$led_qty', '$center_etching_qty', '$border_etching_qty', '$arched_door_glass_qty', '$wood_species', '$stain', '$other', '$user_agent' , '$IP_Address', '$Referer', '$time_stamp', '$email_optin')
";

// insert into the table used for email opt-in processing.
$insert_sql = "INSERT INTO $refrigerated_wine_cabinet_request_table ".$mysql_data;
$status = $db->query($insert_sql);
if (!$status)
error_log("sql error request, sql: INSERT INTO $refrigerated_wine_cabinet_request_table ".$mysql_data);
[CODE]
KristyFord is offline   Reply With Quote
Old 04-30-2012, 07:35 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
DEBUG DEBUG DEBUG
Code:
$insert_sql = "INSERT INTO $refrigerated_wine_cabinet_request_table ".$mysql_data; 
echo "<hr/>DEBUG SQL: " . $insert_sql . "<hr/>\n";
...
What does that show?

I do have to wonder why you need to make $refrigerated_wine_cabinet_request_table a variable. SURELY you don't have more than one table with the same set of fields??? Please say you don't.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 04-30-2012, 08:07 PM   PM User | #3
KristyFord
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
KristyFord is an unknown quantity at this point
Unknown column 'FirstName' in 'field list'

No I don't need to make it a variable...it doesn't work either way. AND no, I don't have multiple tables with the same name...that would be REALLY bad.
KristyFord is offline   Reply With Quote
Old 04-30-2012, 08:12 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Okay, so do this (using a query tool, not PHP...though you can do it in PHP if no other choice):
Code:
DESCRIBE tbl_refrigerated_wine_cabinet_request;
Does that indeed show that you do have a field of that name in that table??
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 04-30-2012, 09:18 PM   PM User | #5
KristyFord
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
KristyFord is an unknown quantity at this point
Unknown column 'FirstName' in 'field list'

Hi, Old Pedant

When I enter the DESCRIBE statement in a phpMyAdmin SQL panel it returns the full table with all the columns and first_name is one of those columns. If I remove the first_name column from my PHP INSERT INTO statement I get the same error for the next column last_name as well. UGH!!
Thanks!
KristyFord is offline   Reply With Quote
Old 04-30-2012, 09:22 PM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Ummm....excuse me, but the query you showed above used FirstName which is NOT AT ALL the same thing as what you just posted, which is First_Name. Yes, the underline in there *IS* significant. (uppercase vs. lowercase is not, however. case doesn't matter in field names.)


Is it possible that is your mistake?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Tags
error, mysql, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:59 AM.


Advertisement
Log in to turn off these ads.