致命错误:在非对象上调用了一个对象方法,在d:\web\reg_0.php 的 136 行
PHP在00BA73CD遇到一个访问错误。这种情况一般是你在使用对象时之前没有声明
如$a = new mysql();
 $a->query();
如果你没使用$a=new mysql();则会出现上述错误

解决方案 »

  1.   

    那样不行啊,mysql_query()这好像是是MYSQL里的函数啊,还要用NEW了吧
      

  2.   

    不用,请描述环境,PHP版本,及部分代码
      

  3.   

    XP系统,版本是5.0吧,下面好像是链接数据库的,
    <?php $pub_inc=1;
    $databaseeng = 'mysql';
    $dialect  = '';class DBbase_Sql {
      var $Host     = "localhost";
      var $Database = "web";
      var $User     = "hyqqp";
      var $Password = "198035";  var $Link_ID  = 0;
      var $Query_ID = 0;
      var $Record   = array();
      var $Row;  var $Errno    = 0;
      var $Error    = "";
      
      var $Auto_free   = 0;   ## Set this to 1 for automatic mysql_free_result()
      var $Auto_commit = 0;   ## set this to 1 to automatically commit results
       function connect() {
        if ( 0 == $this->Link_ID ) {
          $this->Link_ID=mysql_connect($this->Host, $this->User, $this->Password);
          if (!$this->Link_ID) {
            $this->halt("Link-ID == false, connect failed");
          }
          if (!mysql_query(sprintf("use %s",$this->Database),$this->Link_ID)) {
            $this->halt("cannot use database ".$this->Database);
          }
        }
      }  function query($Query_String) {
        $this->connect();    $this->Query_ID = mysql_query($Query_String,$this->Link_ID);
        $this->Row   = 0;
    #    $this->Errno = mysql_errno();
        $this->Error = $this->Database;
        #mysql_error();
        if (!$this->Query_ID) {
          $this->halt("Invalid SQL: ".$Query_String);
        }    return $this->Query_ID;
      }  function next_record() {
        $this->Record = mysql_fetch_array($this->Query_ID);
        $this->Row   += 1;
    #    $this->Errno = mysql_errno();
    #    $this->Error = mysql_error();    $stat = is_array($this->Record);
        if (!$stat && $this->Auto_free) {
          mysql_free_result($this->Query_ID);
          $this->Query_ID = 0;
        }
        return $stat;
      }  function seek($pos) {
        $status = mysql_data_seek($this->Query_ID, $pos);
        if ($status)
          $this->Row = $pos;
        return;
      }  function metadata($table) {
        $count = 0;
        $id    = 0;
        $res   = array();    $this->connect();
        $id = @mysql_list_fields($this->Database, $table);
        if ($id < 0) {
    #      $this->Errno = mysql_errno();
    #      $this->Error = mysql_error();
          $this->halt("Metadata query failed.");
        }
        $count = mysql_num_fields($id);
        
        for ($i=0; $i<$count; $i++) {
          $res[$i]["table"] = mysql_field_table ($id, $i);
          $res[$i]["name"]  = mysql_field_name  ($id, $i);
          $res[$i]["type"]  = mysql_field_type  ($id, $i);
          $res[$i]["len"]   = mysql_field_len   ($id, $i);
          $res[$i]["flags"] = mysql_field_flags ($id, $i);
          $res["meta"][$res[$i]["name"]] = $i;
          $res["num_fields"]= $count;
        }
        
        mysql_free_result($id);
        return $res;
      }  function affected_rows() {
        return mysql_affected_rows($this->Link_ID);
      }  function num_rows() {
        return mysql_num_rows($this->Query_ID);
      }  function num_fields() {
        return mysql_num_fields($this->Query_ID);
      }  function nf() {
        return $this->num_rows();
      }  function np() {
        print $this->num_rows();
      }  function f($Name) {
        return $this->Record[$Name];
      }  function p($Name) {
        print $this->Record[$Name];
      }
      
      function pos(){
       return $this->Row;
      }  function instid() {
        return mysql_insert_id($this->Link_ID);
      }#  function errorno() {
    #    return mysql_errno($this->Link_ID);
    #  }
      
      function halt($msg) {
        printf("</td></tr></table><b>数据库暂时连接故障,请再试一次:</b> %s<br>\n", $msg);
        printf("<b>数据库暂时连接故障,请再试一次:</b>: %s (%s)<br>\n",
          $this->Errno,
          $this->Error);
        die("Session halted.");
      }
    }class SHARP_SQL extends DBbase_Sql {
      var $Host     = "localhost";
      var $Database = "autoweb";
      var $User     = "root";
      var $Password = "";  function free_result() {
        return @mysql_free_result($this->Query_ID);
      }  function rollback() {
        return 1;
      }  function commit() {
        return 1;
      }  function autocommit($onezero) {
        return 1;
      }  function insert_id($col="",$tbl="",$qual="") {
        return mysql_insert_id($this->Query_ID);
      }
      function discount($listprice,$discount){
       $actprice=ture;
       if($discount=="0"){
       $actprice=$listprice;
       }else{
       $discount=$discount/100;
        $actprice=$listprice-($listprice*$discount);
       }
       return $actprice;
      }
        function tax($actprice,$taxrate){
       $taxadded=ture;
       if($taxrate=="0"){
       $taxadded=$actprice;
       }else{
    $taxrate=$taxrate/100;
       $taxadded=$actprice+($actprice*$taxrate);
      
       }
       return $taxadded;
      }
    }
    function prevlink($linkpage,$prevobj,$lcolor,$currentpage,$totalnum,$pagenum){
    $plink="";
    if($currentpage>1){
    $ppage=$currentpage-1;
    if($lcolor==""){
    $plink="<a href=\"$linkpage"."page=$ppage\">$prevobj</a>";
    }
    else{
    $plink="<a href=\"$linkpage"."page=$ppage\"><font color=\"$lcolor\">$prevobj</font></a>";
    }
    }
    return $plink;
    }function nextlink($linkpage,$nextobj,$lcolor,$currentpage,$totalnum,$pagenum){
    $nlink="";
    $npage=$currentpage+1;
    if($totalnum>$currentpage*$pagenum){
    if($lcolor==""){
    $nlink="<a href=\"$linkpage"."page=$npage\">$nextobj</a>";
    }
    else{
    $nlink="<a href=\"$linkpage"."page=$npage\"><font color=\"$lcolor\">$nextobj</font></a>";
    }
    }
    return $nlink;
    }function sendback($reson){ echo "<script>alert(\"$reson\");
    window.location='javascript:history.back()';
    </script>";
    exit;
    }
    ?>
      

  4.   

    php5需要手动配置PHP才能使用MYSQL
    将libmysql.dll复制到system32目录下,
    将php.ini 中,extension = php_mysql.dll前面的;去掉
    然后重启服务器,
      

  5.   

    此代码在php4下没有问题PHP has encountered an Access Violation at ....
    php通路受阻
    这是php5在iis isapi方式下的bug
      

  6.   

    PHP has encountered an Access Violation at ....
    php通路受阻
    这是php5在iis isapi方式下的bug请问楼上的的大虾,这在IIS下要怎么解决啊,
      

  7.   

    回复ice_berg16(寻梦的稻草人)
    里面是这样配置了,但还是不行啊,其它的PHP语法都能运行不会错,就是链不上数据库,你看上面的链接没错吧,是服务器没配好吗
    下面的错误一般在什么情况下会发生 
    Fatal error: Call to undefined function mysql_connect() in d:\web\includes\db.inc.php on line 25
    PHP has encountered an Access Violation at 00BA73CD
      

  8.   

    你在以ISAPI方式安装的?还是换成CGI吧
      

  9.   

    CGI没用过,以前一直是用ASP的,现在搞这个好郁闷,是别人的程序,你在XP的IIS下用过PHP没有
    上面的错误跟程序没有关系吧,
      

  10.   

    Fatal error: Call to undefined function mysql_connect() in d:\web\includes\db.inc.php on line 25
    PHP has encountered an Access Violation at 00BA73CD这是两条信息,请不要连在一起
    Fatal error: Call to undefined function mysql_connect() in d:\web\includes\db.inc.php on line 25
    没有加载mysql支持库或虽已加载但未重起web服务或加载失败PHP has encountered an Access Violation at 00BA73CD
    前面已经说了,这是php5的bug。目前php开发组并未发布解决办法,只有等待
    或改用apache做web服务器
      

  11.   

    哦,谢谢楼上的,
    我以前没学过,只是现在没办法才接触了一下,那意思是说在IIS下就是没有办法解决了吗,