FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » Database discussions » Zero values in fields
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Zero values in fields [message #19820] Mon, 06 September 2004 20:50 Go to next message
Abraxa is currently offline  Abraxa   United States
Messages: 72
Registered: August 2004
Location: Germany
Karma: 0
Member
add to buddy list
ignore all messages by this user
Heya peeps =)

I got a relatively simple problem I guess but I can't figure it out for the life of me.
The deal is that I have zeroes in the fields of a table and when I do a query for those fields the values passed to the PHP variables are empty instead of having a zero in them.

Anyone got an idea about what I can do?

-Abraxa
Re: Zero values in fields [message #19823 is a reply to message #19820] Tue, 07 September 2004 08:15 Go to previous messageGo to next message
dataj1998 is currently offline  dataj1998   Germany
Messages: 31
Registered: June 2004
Location: Germany
Karma: 0
Member
add to buddy list
ignore all messages by this user

It's a difference if you have zeroes (0) or NULL in the field.
What are the types of the fields? Int? Varchar?

If you wanna get the 0 back, they have to be Int or a Varchar where the "string" 0 is in.
Re: Zero values in fields [message #19839 is a reply to message #19820] Fri, 10 September 2004 21:49 Go to previous messageGo to next message
Abraxa is currently offline  Abraxa   United States
Messages: 72
Registered: August 2004
Location: Germany
Karma: 0
Member
add to buddy list
ignore all messages by this user
Thanks for the hints! =)

I fiddled around with MySQL and set the field properties of that column to NOT NULL and lowered the length of the length field (at least I think that's all I did, it was a couple days ago).
I just checked again and to my surprise the query does return the zero values now...

Could it have been the NOT NULL option? Sorry, I'm a beginner in MySQL and couldn't find anything about the exact behavior of that option in the MySQL documentation =\

-Soeren
Re: Zero values in fields [message #19842 is a reply to message #19820] Sun, 12 September 2004 10:32 Go to previous messageGo to next message
dataj1998 is currently offline  dataj1998   Germany
Messages: 31
Registered: June 2004
Location: Germany
Karma: 0
Member
add to buddy list
ignore all messages by this user

The solution with the option "NOT NULL" should do the whole job.

If a field is defined to be not null, you should always get a value back. But please be careful: You should set a default value for that field. If you insert a record and leave out a field with the option set and you don't have a default value, your insert will fail.
Re: Zero values in fields [message #19845 is a reply to message #19820] Sun, 12 September 2004 15:36 Go to previous messageGo to next message
Abraxa is currently offline  Abraxa   United States
Messages: 72
Registered: August 2004
Location: Germany
Karma: 0
Member
add to buddy list
ignore all messages by this user
Thanks a ton, mate!

People like you are who make coding worthwhile and fun - cause you saved me lots of time figuring out why my INSERTs wouldn't o through cause I unknowingly had the exact problem in my table that you made me aware of =D

-Soeren
Re: Zero values in fields [message #19848 is a reply to message #19820] Sun, 12 September 2004 17:37 Go to previous messageGo to next message
dataj1998 is currently offline  dataj1998   Germany
Messages: 31
Registered: June 2004
Location: Germany
Karma: 0
Member
add to buddy list
ignore all messages by this user

np
Re: Zero values in fields [message #20217 is a reply to message #19848] Sun, 03 October 2004 06:50 Go to previous messageGo to next message
alansmith is currently offline  alansmith   United Kingdom
Messages: 49
Registered: February 2004
Location: Seaton Devon
Karma: 0
Member
add to buddy list
ignore all messages by this user
can you make a change to not null when you already have it set differently. Does it affect every table in the database if you only have one db?
Re: Zero values in fields [message #20229 is a reply to message #20217] Mon, 04 October 2004 09:17 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
Yes, but it won't affect existing values.

FUDforum Core Developer
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: 2 Fud Forums, Can I combine users
Next Topic: Determining when to use INSERT or UPDATE
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Dec 18 01:55:28 EST 2017

Total time taken to generate the page: 0.00742 seconds