I'm trying to do a simple if/then statement with the code below

IF(is_null($Row["DELIV_DATE"]))
		{$RowDELIV_DATE = "";}
		ELSE
		{$RowDELIV_DATE = convert_datetime($Row["DELIV_DATE"]." 12:00:00");}

and I keep getting errors because it's trying to run a null value through my convert_datetime function. When I do the following:

var_dump(is_null($Row["DELIV_DATE"]));

I get "bool(true)".

Any ideas on how to get this to work?

    Any difference if you use [man]empty/man instead of [man]is_null/man? empty() would also trigger if the value is an empty string, 0, or boolean false, whereas is_null() will only trigger if the variable is explicitly set as null. If that's not the issue, it might be a logic error or simple typo elsewhere, but I'm not seeing anything in that little bit of code.

      nope, no difference. I would post all my code but didn't want to take up the whole screen and am limited with the 10,000 character limit (as mine is 13,333 characters long). I'm just trying to see if there's a value in there already and if it is then display it in my option and if not then give me blank in my option. There has got to be an easier way to do this other than what I'm already doing. you know what, I'll just attach it.

        DKY;10963537 wrote:
        		{$RowDELIV_DATE = convert_datetime($Row["DELIV_DATE"]." 12:00:00");}
        

        and I keep getting errors because it's trying to run a null value through my convert_datetime function.

        No you're not. Even if $Row["DELIV_DATE"] did contain null, empty string or whatever, you are pasing " 12:00:00" to your conversion function. It's also super easy to check what is actually passed to this function by putting echo or error_log at the very top of it

        function convert_datetime($arg) {
        	echo $arg;
        	...
        }

        I know that using UC language constructs or disregarding casing is ok for functions. It is however not for variables. Since pretty much everyone is using if and else while you're writing IF and ELSE, could it be that you are ignoring variable casing? Consider

        function out($s) { echo $s; }
        
        $string = 'Text';
        OUT($string);    // function call ok, variable ok
        out($STRING);	// function call ok, no variable $STRING
        

        How about trying to post relevant code instead of everything? Say perhaps code for the convert_date function, which I seriously doubt is 13k characters.

          Just figured it out, thanks! I changed the default to '0000-00-00' in the database and did a if <> "0000-00-00" and it seems to work out.

            Write a Reply...