为什么一行中的一个字段在php / mysql数据集中返回null(当它没有时)?

为什么一行中的一个字段在php / mysql数据集中返回null(当它没有时)?

问题描述:

I have a set of data returning and everything looks good except for one row -- Im looking into the database and the field (locationName) on that row has a value ... i have NO IDEA why this one row keeps returning NULL.

Here is the query :

if( $result = mysqli_query($mysqli, "SELECT locID, LocationName, Address, Address2, City, State, Zip, PhoneWork, Email FROM tnLocation WHERE locEnabled = 1 ORDER BY LocationName")) {  

        $rows = array();
        //fetch associative array
        while ($row = mysqli_fetch_assoc($result)) {
            $rows[] = $row;
        }        
        echo json_encode($rows);
        mysqli_free_result($result);         
    }

Here is a shot of the table:

The table with the field that is returning NULL

And here is what is coming back in the object:

The object with null

I am completely at a loss here.. everyone of the other rows is just fine. If I copy and paste my query right into my phpMySQL it comes back with the name ... ?

我有一组数据返回,一行看起来很好,除了一行 - 我正在查看数据库和 该行上的field(locationName)有一个值...我没有IDEA为什么这一行保持返回NULL。 p>

这是查询: strong> p>

  if($ result = mysqli_query($ mysqli,“SELECT locID,LocationName,Address,Address2,City,State,Zip,PhoneWork,Email FROM tnLocation WHERE locEnabled = 1 ORDER BY LocationName  “)){
 
 $ rows = array(); 
 //获取关联数组
而($ row = mysqli_fetch_assoc($ result)){
 $ rows [] = $ row; 
} \  n echo json_encode($ rows); 
 mysqli_free_result($ result);  
} 
  code>  pre> 
 
 

以下是该表格的一部分: strong> p>

p>

以下是 回到对象中: strong> p>

p>

我在这里完全不知所措..其他行的每个人都很好。 如果我将查询复制并粘贴到我的phpMySQL中,它会返回名称...? p> div>

My guess is json_encode() is panicking and converting the field to null, possibly due to the data not being encoded in UTF-8. If you var_dump() the row, does everything look normal?