dounaidu0204 2016-09-26 08:49
浏览 53
已采纳

期望参数1是资源,布尔给定,查询使用前1个顺序通过desc [duplicate]

i still new in sqlserver and i trying to fetch database like this

$sql = "select top 1 pdate from j2365join_transaction_old where order by pdate desc";
$mulaisql = sqlsrv_query($sqlconn2, $sql, array(), array( "Scrollable" => 'static'));
$mulai = sqlsrv_fetch_array ($mulaisql, SQLSRV_FETCH_ASSOC);
print_r ($mulai);

but go error

sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given

, can someone explain to me why i got this error, thanks

</div>
  • 写回答

1条回答 默认 最新

  • dongyao2022 2016-09-26 08:52
    关注

    Error in your query my friend.

    $sql = "select top 1 pdate from j2365join_transaction_old where order by pdate desc";
    

    You should write condition after where clause. If there is no WHERE condition then please remove WHERE clause. So your query will we right

    $sql = 'select "top 1 pdate" from j2365join_transaction_old  order by pdate desc';
    

    Generally you should not use spaces in column, although you have done then you can read it by using

    Quote ("field name")

    Large brackets

    "[field name]"

    With backticks

    SELECT * FROM `Area One`
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?