0
我得到了一些空值通過返回我的mysql_query
在json記法從PHP。有些領域,比如bookid,名稱,作者,持續時間都是返回值,其他不是!但是我在DBVisualizer中輸入了相同的查詢,而且我只有價值...這裏有什麼問題?mysql_query返回值和空值,但應該只有值
echo $myuserid . "idcheck";
$q1 = "select u.address as address, u.postcode as postcode, u.town as town, u.telnumber, u.mail, b.bookid as bookid, b.name as name, b.author as author, s.duration as duration from status s, book b, user u where s.bookid = b.bookid and s.borroweruserid = u.userid and s.borroweruserid = $myuserid";
echo $q1;
$sth = mysql_query($q1) or die(mysql_error());
while($rowla = mysql_fetch_assoc($sth)) {
$rows[] = array(
'address' => $rowla['address'],
'postcode' => $rowla['postcode'],
'town' => $rowla['town'],
'telnumber' => $rowla['telnumber'],
'mail' => $rowla['mail'],
'bookid' => $rowla['bookid'],
'name' => $rowla['name'],
'author' => $rowla['author'],
'duration' => $rowla['duration']);
// 'pic' => base64_encode($row['pic']
//$rows[] = $r;
}
$j1 = json_encode($rows);
UPDATE:當把error_reporing到PHP腳本沒有什麼作品(不執行查詢),並通過添加的print_r($ rowla),而 後,仍然得到這個反饋(第二查詢在做同樣的 - 只是一個位不同): http://s24.postimg.org/4wpu29zwl/Screen_Shot_2014_05_22_at_08_45_02.png
所以,如果我理解正確的你,如果你DBVisualizer工具中運行'q1',有顯示沒有空/空值,但裏面'j1'你對某些領域得到空/空值? – asprin
@asprin,你是對的 – flyOWX
嘗試把'error_reporing(E_ALL)'放在你的php腳本的頂部,看看是否打印任何東西?通知,警告等。 – asprin