English 中文(简体)
致命错误: 要求成员履行非目标的职能
原标题:Fatal error: Call to a member function fetch() on a non-object
  • 时间:2012-01-12 13:22:51
  •  标签:
  • php

我有这份PHP代码,其中我从数据库中得出一个减少名单。 但是,当我提出申请时,它就产生了一个错误<代码>。 致命错误: 要求成员在议会中担任非目标职务。 php on line 79.

<select name="country">
<?php
    $country_result = $dataclass->get_Countries();
    while ($country_row = $country_result->fetch()){ //line 79
        echo "<option value= " . $country_row["country_id"] . " >" . $country_row["country_name"] . "</option>" . "
";
    }
?>
</select>

我在任何地方都使用过这种方法,而且他们工作,但在利用这种方法来缩小名单时,我没有工作。

获取_国家方法内容:

function get_Countries() {
    $sql = "SELECT * FROM tbl_countries;";
    return $this->dbconn->fetch($sql);
}

(b) 内容:

function fetch($sql, $data=array()) {
    try{
        $STH = $this->dbh->prepare($sql);
        $STH->setFetchMode(PDO::FETCH_ASSOC);
        $STH->execute($data);
        return $STH;
    } catch (PDOException $e){
        echo $e->getMessage();
    }
}

这是因为数据参数是一个阵列吗?

问题回答

提 出

function get_Countries() {
    $sql = "SELECT * FROM tbl_countries;";
    return $this->dbconn->query($sql);
}




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签