RE: [PHP] Variable value doesn't stay "Null"

From: Date: Thu, 15 Mar 2001 20:00:39 +0000
Subject: RE: [PHP] Variable value doesn't stay "Null"
Groups: php.general 
Request: Send a blank email to php-general+get-44111@lists.php.net to get a copy of this message
So how do I get the PHP script that stores the information in the My SQL database to not store "0"? a "0" value is a valid value for this variable. I don't want 0 to be the value of the variable if nothing is entered. Right now, the database is populated with 0's for the fields that are not filled in. -----Original Message----- From: Chris Lee [mailto:lee@mediawaveonline.com] Sent: Thursday, March 15, 2001 8:17 AM To: php-general@lists.php.net Subject: Re: [PHP] Variable value doesn't stay "Null" null is a bad idea. if a value is set to null in a table then that variable will not be set. name phone fax email chris lee 3771095 5541120 NULL $result['name'] is 'chris lee' $result['phone'] is '3771095'; $result['fax'] is '5541120'; $result['email'] is an undefined variable in php a variable is set or not set. if it set to '' its still set, if a variable is undefined, then it is null. -- Chris Lee lee@mediawaveonline.com "Michael Conley" <mconley@RentHistory.com> wrote in message news:2102328FD2ECD411879E00609737BFD10333E3@FATBOY... I put up an HTML page that allows a user to modify some previously entered information. The information is taken from a MySQL database and displayed on the page. The user can leave the data alone or modify it. If there is no information in the database for one of the fields, the input box is empty. The problem is that when I submit this information, the page that is called does not receive the variables from fields with no information as "null". Instead, it gets them with something other than null, although if I print the variable, they come out blank. I check the variable using "is_null" and they evaluate as not being null. When my script then enters the information into the MySQL database, a value of "0" is entered for the numeric fields. Having these "0" values in the database gives me the wrong information. Any idea why an input field that is populated with a null value would go to the next page as a not null value (although no value shows up for it until it is written to the database)? ---------------------------------------------------------------------------- ---- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#44111) next »