Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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]

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,028
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •