php錯誤
原諒我第一次在php編碼。我正在嘗試將數據從drupal導出到json文件。
研究,我應該缺少「}]或事情的經過,但在9號線或10php解析錯誤:語法錯誤,意外T_VARIABLE我
我找不到10號線是
$items['message/json'] = array(
的錯誤是:
Parse error: syntax error, unexpected T_VARIABLE in line 10
<?php
/**
* Implementation of hook_menu()
*/
function message_menu(){
$items = array();
$items['message/json'] = array(
'title' => 'Json callback',
'page callback' => 'message_json_page',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
*json call back
*/
function message_json_page() {
$sql = 「SELECT n.nid , n.title as name, b.body_value as message FROM {node} n INNER JOIN {field_data_body} b ON n.nid = b.entity.id WHERE n.status = 1 and n.type = :type」
$result = db_query($sql, array(‘:type’ => ‘message’))->fetchAll();
$json_value = json_encode($result);
print $json_value;
}
您還在爲'$ sql'結尾使用分號';',並且在$ sql中使用了引號'''''''''而不是標準引號''''''''' ''和'$結果' – Sean 2014-10-22 04:32:25
那些時髦的語錄會讓你的一天感到沮喪。 – 2014-10-22 04:33:04
你的報價有問題。 – sectus 2014-10-22 04:33:25