|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Checkbox to MYSQL--can't get value into TINYINT field
Here's my question:
I have a TINYINT(1) field, supposed to be populated from a checkbox--checked or not. When run the thing, here's the query that gets generated--note the Inactive='on' near the end. That's the part that, I thought, would populate my Inactive field with a binary value. Does it have something to do with the 'on' being in quotes? FirstName='Johnson',LastName='Mon',Title='',CellPh one='',HomePhon e='',email='',StreetAddress='',City='',State='',Zi pCode='ZipCode' ,Inactive='on' WHERE EmployeeNo=8 Two code snippets to clarify: Here's the checkbox code: <input type="checkbox" name="Inactive" <?php echo $Inactive ? "checked" : ""?> /> and here's the INSERT in php: $sql = "INSERT INTO fieldcrew (FirstName,LastName,Title,CellPhone,HomePhone,emai l,StreetAddress ,City,State,ZipCode,Inactive) VALUES ('$FirstName','$LastName','$Title','$CellPhone','$ HomePhone','$em ail','$StreetAddress','$City','$State','$ZipCode', '$Inactive')"; it's getting the rest of the data--what's gone wrong??? Thanks! Steve |
|
#2
|
||||
|
||||
|
Tinyint is an integer value: a number. You're trying to write a string to it, so it stores the integer value of that string: 0.
you'll probably want to populate the `inactive' column with either 0 or 1, depending on whether it's checked or not. Easiest way to see if it's checked is by using the isset() function, like this: PHP Code:
__________________
This is my code. Is it not nifty? "The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools." ---Douglas Adams Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 264
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Checkbox to MYSQL--can't get value into TINYINT field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|