dongqiao8417 2015-01-21 16:49
浏览 77
已采纳

我收到警告:fwrite()期望参数1是资源,给定null

So I am getting this warning and I cannot figure out what is wrong with the code. The section of code that its pointing to is shown below.

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);

$adconn = ldap_connect("ldap://earth.matcor-matsu.com") or die("Couldn't connect to AD!");

//------1
if($adconn){
    echo fwrite($log,'$adconn : ' . $adconn. "
");
    echo fwrite($log,"
");
}else{
    echo 'Unable to connect to LDAP server';
}
  • 写回答

1条回答 默认 最新

  • dongshenyu4638 2015-01-21 16:54
    关注

    $log needs to be set with a fopen('data.txt', 'w') (example). You need to tell the PHP what the file handle actually is.

    http://php.net/manual/en/function.fwrite.php

    before the if statement also output by writing:

    var_dump($log) to check you've got a valid value of $log - as in not NULL

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统