SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old August 1st, 2006, 03:46 PM
bevenro bevenro is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 4 bevenro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 3 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old August 2nd, 2006, 05:41 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 34 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
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:
 $Inactive = (isset($_POST['Inactive']) ? 0); 
__________________
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Checkbox to MYSQL--can't get value into TINYINT field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway