Insert Checkbox value in mysql using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Martin
    New Member
    • Oct 2011
    • 1

    #1

    Insert Checkbox value in mysql using php

    <input name="like" type="checkbox" value="yes" checked/>

    _______________ _______________ _______________ _____________

    if(isset($_POST['like'])){

    $likeuser = "yes";

    mysql_query("IN SERT INTO comments (LJ)
    VALUES ('$likeuser')") or die ("could not add like yes " . mysql_error());

    } else {

    $likeuser = "no";

    mysql_query("IN SERT INTO comments (LJ)
    VALUES ('$likeuser')") or die ("could not add like no " . mysql_error());

    }


    -----------------------------------------------
    mysql LJ varchar(10)


    ERROR:
    could not add like yes Unknown column 'LJ' in 'field list'

    i want to add value "yes" if check is selected by user and "no" for user not checked.

    Thanks in advance.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It's saying that there's no field named LJ in your comments table.

    Comment

    Working...