List <select> has two values!

2 posts by 2 authors in: Forums > CMS Builder
Last Post: September 21, 2012   (RSS)

Re: [Perchpole] List <select> has two values!

Hi,

We've done some local testing and we think we've recreated the problem. Have you added the list field after some entries had already been added to the table? We found that creating new entries or modifying old entries put an empty string in the column. But entries that were created before the list field was added had a value of null in that column. Is this the same problem your experiencing?

Also how are you detecting the null value? If it's through a PHP if statement you could use a == instead of is_null() to detect if the field is empty as it treats null and empty strings in the same way.

if($row['list'] == ""){
//This will treat both null and an empty string as true
}
if(is_null($row['list'])){
//This will only be true for values of null.
}


If you are detecting null through a MySQL WHERE statement then the solution would be to use a where statement similar to this:

WHERE ( testlist IS NULL OR testlist = '' )

Thanks!

Greg
Greg Thomas







PHP Programmer - interactivetools.com