Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-20-2005, 01:29 AM   PM User | #1
Taylor_1978
Regular Coder

 
Join Date: Jun 2003
Location: Australia
Posts: 506
Thanks: 6
Thanked 7 Times in 7 Posts
Taylor_1978 is on a distinguished road
Negative value in a table

Hiya,

I am trying to enter a value in a field set to INT(11), but it will not allow negative numbers. What should this field be to allow such a value?

Thanks in advance!

Taylor.
Taylor_1978 is offline   Reply With Quote
Old 01-20-2005, 02:13 AM   PM User | #2
dniwebdesign
Regular Coder

 
dniwebdesign's Avatar
 
Join Date: Dec 2003
Location: Carrot River, Saskatchewan
Posts: 677
Thanks: 3
Thanked 2 Times in 2 Posts
dniwebdesign is an unknown quantity at this point
varchar should be able to hold the value... then when you retrieve it just do a simple math problem to verify you want it an integer.

Example PHP:
PHP Code:
$negativevalue=$row["column"];

$value=$negativevalue*1;

//Do whatever you want with the negative $value 
I believe this should do what you want.
__________________
Dawson Irvine
CEO - DNI Web Design
http://www.dniwebdesign.com
dniwebdesign is offline   Reply With Quote
Old 01-20-2005, 03:51 AM   PM User | #3
Kiwi
Regular Coder

 
Join Date: Oct 2002
Posts: 379
Thanks: 0
Thanked 0 Times in 0 Posts
Kiwi is an unknown quantity at this point
Alternatively, you could check the variable definition. It's likely to be defined as UNSIGNED. Note that mySql automatically adds the unsigned property to any field set to ZEROFILL: zerofill is really designed for index columns (keys and foreign keys), where a negative number doesn't make any sense

Putting numberical values in a char field is both wasteful and inefficient.

If all else fails, you might want to take a look through the manual.
__________________
Strategy Conscious
Kiwi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:10 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.