查询当isdel字段等于0时的记录$strWhere="(isDel=\"0\") and Name like '% $strKeyWord %'";if ($strWhere!="0"){
$strSQL="select * from contract where".$strWhere;
}else{
$strSQL="select * from contract where (isDel=\"0\")";
}结果输出$strWhere 和 $strSQL 均为空,
提示:Warning: mssql_query() [function.mssql-query]: message: 第 1 行: 'where' 附近有语法错误。
大家帮忙看看是哪里写错了,谢谢

解决方案 »

  1.   


    $strWhere=" (isDel='0') and Name like '% $strKeyWord %'";<==注意前面要空一个字符。if ($strWhere!="0"){//你这个判断什么?判断$strWhere字符长度?
    $strSQL="select * from contract where".$strWhere;
    }else{
    $strSQL="select * from contract where (isDel='0')";
    }
      

  2.   

    if ($strWhere!="0") 这个判断$strWhere 是否为空
      

  3.   

    Warning: mssql_fetch_row(): supplied argument is not a valid MS SQL-result resource in C:\Apache2\htdocs\contract\admin\Browse.php on line 56
    select * from contract where
    Warning: mssql_query() [function.mssql-query]: message: 第 1 行: 'where' 附近有语法错误。 (severity 15) in C:\Apache2\htdocs\contract\admin\Browse.php on line 83
      

  4.   


    $strWhere=" isDel='0' and Name like '% $strKeyWord %'";<==注意前面要空一个字符。if (!empty($strKeyWord)){//你这个判断什么?判断$strWhere字符长度?
    $strSQL="select * from contract where".$strWhere;
    }else{
    $strSQL="select * from contract where isDel='0'";
    }这个字段你已经定义有字符,所以永远不为空!
      

  5.   

    谢谢问题解决,应该是这个where (isDel='0')