解析错误:语法错误,第23行/web/htdocs/www.aieci.it/home/Ptp145a000/salva.php中的意外'$ Database'(T_VARIABLE)

时间:2017-05-23 07:45:03

标签: php mysql

我在以下代码中遇到此错误,但我无法解决。 我已经使用十六进制编辑器进行了操作,一切似乎都没问题。 有人能帮助我吗?

在另一个php文件中定义的数据库在开头用include语句调用。

代码如下:

<?php
// -----------------------------------------------------------
// INCLUSIONE FILE
// ----------------------------------------------------------------------
$GLOBALS['HomeDir']=substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], "")); //Rilevo Home directory

require_once "Include/Include.php"; //Inclusioni generali

if (isset($_GET["id"]) and isset($_GET["variabile"]) and isset($_GET["da"]) and isset($_GET["a"])){
    $Nome="storico.csv";
    header("Content-Type: application/text");
    header("Content-Disposition: attachment; filename=".$Nome);
    $Iden=$_GET["id"];
    $Variab=$_GET["variabile"];
    $Start=$_GET["da"];
    $End=$_GET["a"]; 
    if ($GLOBALS['Db']->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    if (isset($GLOBALS['Db'])
    $Database=$GLOBALS['Db']->get_results("SELECT DateTime, Value FROM ".RESTDATA." WHERE (UID = '".$Iden."' AND Field = '".$Variab."' AND DateTime >= '".UnixToMySQLTime($Start)."' AND DateTime <= '".UnixToMySQLTime($End)."' ORDER BY ID ASC;");
    }
    foreach ($Database as $Data){
    print "'".gmdate("d/m H:i", MySQLToUnixTime($Data->DateTime))."';".$Data->Value."n"; //Scrivo in tabella dato

}
?>

1 个答案:

答案 0 :(得分:0)

)

中缺少另一个if
if (isset($GLOBALS['Db']))
    $Database=$GLOBALS['Db']->get_results("SELECT DateTime, Value FROM ".RESTDATA." WHERE (UID = '".$Iden."' AND Field = '".$Variab."' AND DateTime >= '".UnixToMySQLTime($Start)."' AND DateTime <= '".UnixToMySQLTime($End)."' ORDER BY ID ASC;");
    }