php解析错误:语法错误,意外T_VARIABLE我
问题描述:
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;
}
答
查询中您的报价存在一些问题,我已对其进行修改,请现在核实。
<?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;
}
?>
+1
谢谢空白头我用你的代码,我现在可以打开页面。但在页面上的错误是在第27行。我会检查我的SQL数据库,它看起来像我只需要编辑代码正在寻找。感谢您的帮助! – cmdace 2014-10-22 20:39:43
您还在为'$ sql'结尾使用分号';',并且在$ sql中使用了引号'''''''''而不是标准引号''''''''' ''和'$结果' – Sean 2014-10-22 04:32:25
那些时髦的语录会让你的一天感到沮丧。 – 2014-10-22 04:33:04
你的报价有问题。 – sectus 2014-10-22 04:33:25