0

我有这个代码

{ <?php
include 'koneksi.php';

$idAgent = $_GET["rqid"];
$ipAgent = $_SERVER['REMOTE_ADDR'];

$app = $_GET["app"];
$action = $_GET["action"];

$org = $_GET["org"];
$des = $_GET["des"];

$trainNo = $_GET["train_no"];
$depDate = $_GET["dep_date"];

$query = "SELECT cekRQID('$idAgent','$ipAgent') as jml;";
//echo($query);
$hasil = mysql_query($query);
$data  = mysql_fetch_array($hasil);
$channelOK = $data['jml'];  

if ($channelOK == "1") {
    if ($app == "information" && $action == "get_seat_map") {

        $query="SELECT 0 as err_code, '$org' as org, '$des' as des, '$trainNo' as train_no, $depDate as dep_date ";
        $hasil1 = mysql_query($query);

        $rows1 = array();
        while ($r1 = mysql_fetch_assoc($hasil1)){
            $rows1 = $r1;
        }

        $tglnya = date('Ymd',$depDate); //STR_TO_DATE('$depDate','%Y%m%d')

        $query = mysql_query("CALL GET_SEAT_MAP('$org','$des','$trainNo',STR_TO_DATE('$depDate','%Y%m%d'),@TEST);") or die mysql_error();
        $query = mysql_query("SELECT @TEST;") or die mysql_error();
        //echo($query);
        while($row = mysql_fetch_row($query))
        {           
            $query = $row[0];
        }

        $hasil = mysql_query($query);
        //echo($query);


        $rows = array();
        $index= 0;
        $bufk0 = "";
        $body = 0;

        while ($r = mysql_fetch_row($hasil)){
            $curfk0 = $r[0].$r[1];
            if( $bufk0 != $curfk0 ){
                $head[$curfk0] = array ( $r[0],$r[1]);  
                $out2[$curfk0][] =  array( $r[2],$r[3],$r[4],$r[5],$r[6],$r[7] );
            } else {                    
                $out2[$curfk0][] =  array( $r[2],$r[3],$r[4],$r[5],$r[6],$r[7] );                   
            }               
            $bufk0 = $r[0].$r[1];
            $bufindex = $index;
            $headindex = $head ;
            $index++;
        }

    }

if (is_array($values)){
    foreach ($head as $key => $val ){
        $final['seat_map'][] = array( $val[0],$val[1], $out2[$key] );       
    }   
}


header('Content-type: application/json');
echo json_encode($rows1+$final);
}

?>

}

当我运行此代码时,我收到一些错误消息:解析错误:语法错误,第 37 行 /var/www/html/sgetseatmap.php 中的意外 T_STRING

这是在代码中:

$query = mysql_query("CALL GET_SEAT_MAP('$org','$des','$trainNo',STR_TO_DATE('$depDate','%Y%m%d'),@TEST);") or die mysql_error();

我只是无法弄清楚为什么会在这里发生,非常感谢任何帮助。

4

1 回答 1

3

您在两行中有以下内容:

or die mysql_error();

虽然您应该为检查错误而受到称赞(在我们看到的问题中很少见),但这种语法是错误的。die是一个函数,所以参数必须在括号中:

or die(mysql_error());

另一方面,您也应该停止使用 mysql_xxx 函数,因为它们已被弃用。您应该使用 PDO 或 mysqli,并且最好使用带参数的预处理语句而不是插值字符串。

于 2013-09-19T00:33:01.487 回答