Input Checkbox and PHP $_POST

Discussion in 'PHP' started by JA12, Apr 17, 2009.

  1. #1
    I've got an

    
    <input type="checkbox" name="Display" value="Yes" />
    
    Code (markup):
    The print_r of $_POST

    
    Array ( [Display] => Yes ) 
    
    Code (markup):
    and obviously, if the checkbox is not checked, then [Display] doesn't feature.

    But later I have

    
    if (isset($_POST['Display'])) {
      $display = 1;
    } else {
      $display = 0;
    }
    
    Code (markup):
    I get:
    
    MySQL Error: Unknown column 'Display' in 'field list'
    
    Code (markup):
    What is going on? :confused:

    I thought I was doing the right thing with isset!
     
    JA12, Apr 17, 2009 IP
  2. dumaas

    dumaas Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The error you are getting is from MySQL query, and doesn't have "anything" to do with these _POST variables.

    Without seeing more of the script it's hard to help more.

    Do you have Display column in your database table?
     
    dumaas, Apr 17, 2009 IP
  3. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #3
    It's clearly said that there's no column called 'Display' - add it and it'll disappear !
     
    ActiveFrost, Apr 17, 2009 IP
  4. JA12

    JA12 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ah, yes...

    I was so fixated on the Display bit from the form, that I totally missed the fact that the error was a MySQL error and not a form thing...

    Thanks everyone for pointing that out!
    :D
     
    JA12, Apr 18, 2009 IP