Selects coming across

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • The1corrupted
    New Member
    • Feb 2007
    • 134

    Selects coming across

    This is currently befuddling me and it's a little bit of html/php but the thing that isn't working is the php...

    Basically, my issue is that my <select> doesn't create a text value to be input into a mysql table like so...

    Page 1
    Code:
    <select name='name'>
    <option value='Yay'>yay</option>
    </select>
    and I'm trying to input it into a mysql table...
    [PHP]
    <?php
    $nam=$_POST['name'];
    mysql_query("IN SERT INTO `user_table`(`n ame`) VALUES ('$nam');
    ?>[/PHP]

    The field Name is set as a text type, and I am confused as to what is wrong.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    To start, your query is incorrectly specified, like not closing the string
    Code:
    mysql_query("INSERT INTO `user_table`(`name`) VALUES ('$nam');
    should be
    Code:
    mysql_query("INSERT INTO `user_table`(`name`) VALUES ('$nam')");
    Otherwise it means that you have another error, because at first sight the code looks ok, but I am missing the other code around your select box.

    So show all code involved, including the form definition and the start of your php code to catpure the POSTed variables.

    Ronald :cool:

    Comment

    Working...