PHP无法正确解析查询结果

时间:2015-04-10 08:09:24

标签: php mysql sybase

当我运行一些PHP代码时,我遇到了我无法解释的错误。我正在运行PHP的查询。

  

警告:sybase_query()[function.sybase-query]:Sybase:Server   消息:' ='附近的语法不正确。 (严重程度15,程序N / A)in   第20行的C:\ xampp \ htdocs \ wil \ Testen \ ZKO-backend \ php \ ui_table.php

  

警告:sybase_fetch_array()期望参数1是资源,   给出的布尔值   第21行的C:\ xampp \ htdocs \ wil \ Testen \ ZKO-backend \ php \ ui_table.php

调用的查询在Sybase中运行完美,同一例程在类似查询上运行完美

我得到了查询提供的每条记录的错误,所以我认为问题应该在PHP代码中,该代码无法处理查询的输出。

查询:

<?PHP
$subquery= "SELECT distinct
ds_u_in.DATASET_ID,
 ds_u_in.USED_INSTRUMENT_ID,
 '<td>' + inv_in_type.NAME +'</td>' AS LONG_TABLEROW,
 '<td>' + per_org_man.NAME +'</td>' AS LONG_TABLEROW2,
 '<td>' + inv_in.SERIAL +'</td>' AS LONG_TABLEROW3,
 '<td>' + per_org.NAME +'</td>' AS LONG_TABLEROW4,
 '<td>' + inv_in.DEPARTMENT +'</td>' AS LONG_TABLEROW5

FROM 
 dataset..DATASET_USED_INSTRUMENT ds_u_in,
 inventory..USED_INSTRUMENT inv_u_in,
 inventory..INSTRUMENT_TYPE inv_in_type,
 inventory..INSTRUMENT inv_in,
 person..ORGANISATION per_org_man,
 person..ORGANISATION per_org

WHERE ds_u_in.USED_INSTRUMENT_ID = inv_u_in.USED_INSTRUMENT_ID
  AND inv_u_in.INSTRUMENT_TYPE_ID = inv_in_type.INSTRUMENT_TYPE_ID
  AND inv_u_in.INSTRUMENT_ID *= inv_in.INSTRUMENT_ID
  AND per_org_man.ORGANISATION_ID =* inv_in_type.MANUFACTURER_ORGANISATION_ID
  AND per_org.ORGANISATION_ID =* inv_in.ORGANISATION_ID
  AND ds_u_in.USED_INSTRUMENT_ID = {K} ";
?>

在执行查询之前,{K}被整数替换。

显示结果的PHP代码:

            for ($k = 1; $k <= $_SESSION[$name]; $k++) {
            $mysubquery=sybase_query(str_replace('{K}',$_SESSION[$name.'_'.$k],$subquery));
            $subrow = sybase_fetch_array($mysubquery);
            if ($subrow)  { 
                if (isset($subrow["LONG_TABLEROW"])) {
                    if(strlen($subrow["LONG_TABLEROW"]) >=1) {
                        echo "<tr>".$subrow["LONG_TABLEROW"];
                        for ($l = 2; $l <= 9; $l++) {
                            if (isset($subrow["LONG_TABLEROW".$l])) {
                                if (strlen($subrow["LONG_TABLEROW".$l]) >=1) {
                                    echo $subrow["LONG_TABLEROW".$l];
                                }
                            }
                        } 
                    } 
                }
                echo '<td><img onclick="javascript:DeleteLine())" src="images/trash.png" /> ';
                if ($k == $_SESSION[$name] ) { 
                    echo 'add' ;
                }
                echo '</td></tr>';
            }
        }

有人看到这里出了什么问题吗?

0 个答案:

没有答案