SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Y or N in MySql

  1. #1
    SitePoint Addict suzkaw's Avatar
    Join Date
    Apr 2002
    Location
    North Carolina
    Posts
    338
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Y or N in MySql

    I have a simple check box that I would like the place a Y if it is checked and of course N if not. Or heck even 1 or 0. Ok any way I have the checkbox set up
    Code:
    <input name="3party" type="checkbox" id="3party" value="y" checked>
    But when I insert it into the DB all I get is $

    Here is my insert statement:
    Code:
    $query = "INSERT INTO  registro_signup (name, email, address, city, state, zip, gender, 3party) values ('$name', '$email', '$address', '$city', '$state', '$zip', '$gender', '$3party')";
    Oh and my field is set up as Char(1) if that helps
    Thanks Eric.

  2. #2
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    name the var something else
    Mike
    It's not who I am underneath, but what I do that defines me.

  3. #3
    jigga jigga what? slider's Avatar
    Join Date
    Oct 2002
    Location
    Utah (USA)
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One option to look at is making your DB field enum('Y', 'N'). Probably doesn't affect your problem, but that's the first thing I thought of when I started reading your post.

    I think your problem is you can't start a variable name with a number... not sure if PHP holds to this though (can't find anything on it), but seems like it does.
    $slider = 'n00b';

  4. #4
    SitePoint Member insomica's Avatar
    Join Date
    Apr 2003
    Location
    Houston, TX
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can't start a variable with a number. only a letter or an underscore.

    Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

    Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
    http://www.php.net/manual/en/language.variables.php
    BitWise Sreen Name - insomica
    File Size of Bitwise is only 595k.
    They are working on version for linux.
    http://www.schwippy.com/insomica/


  5. #5
    SitePoint Addict CeleronXL's Avatar
    Join Date
    Dec 2002
    Location
    United States of America
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, 'lest you have register_globals on, I hope you're declaring that

    $threeparty = $_REQUEST['threeparty'];

    Assuming you'd change 3party to threeparty.

    You could, of course, use $_POST or $_GET, but I don't know which kind of action you're using, and $_REQUEST will work for both.

  6. #6
    SitePoint Addict suzkaw's Avatar
    Join Date
    Apr 2002
    Location
    North Carolina
    Posts
    338
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks everyone. Learn something new everyday
    Thanks Eric.


Bookmarks

Posting Permissions

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