PHP Array Null Values

The attached code does not work.  What I am attempting to do is to only update records that do not have a null value but the code is updating the field to "0000-00-00" vs leaving it null.   Any suggestions?  Thank you.
$i = 0;
        foreach ( $dateAssignedArray as $editID => $da) {
          if (!empty($dtAssigned)){$update="UPDATE audit SET dateAssigned='$da' WHERE auditID=$editID";

        $updateRow=mysql_query($update)or die(mysql_error());
          ELSE {

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hugh McCurdyCommented:
I'm not sure but I'll guess.  I suggest some var_dump() calls on $da and $dtAssigned.  I wonder if rtrim() is somehow having trouble with a null string.  I don't see a definition for that case at

Perhaps you should require that both $dtAssigned and $da not be empty.

if ( ( !empty ( $dtAssigned )) && ( !empty ( $da )))  

Open in new window

If that doesn't fix it, please try the var_dump() so we can see what's going on.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rcowen00Author Commented:
After running your suggestion, it didn't work but I realized because the field already had "0000-00-00" and I was deleting it, but that wasn't being looked at because it was null.  I realized that in most cases that will work when the current value is null but what if the user has a value in the field but wants to remove it, this will never work.  I believe then I want to check for isset.
Hugh McCurdyCommented:
Data in the field would do it.  Thus the value of var_dump().  Glad you got it solved and thanks for the points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.