Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

后端 未结 6 849
耶瑟儿~
耶瑟儿~ 2020-11-21 05:35

I get the error when trying to run this:

query(         


        
6条回答
  •  一个人的身影
    2020-11-21 05:49

    Your query must have a problem which is causing $result to be an invalid resource.

    Try checking for mysql_error() after the line on which you run your query.

    Edit:

    In fact, I would alter your DBConnector class function query() to something like the following, so that an identifiable error is thrown when you have a bad query:

    function query($query) {
        $this->theQuery = $query;
        $queryId = mysql_query($query,$this->link);
        if (! $queryId) {
            throw new Exception(mysql_error().".  Query was:\n\n".$query."\n\nError number: ".mysql_errno();
        }
        return $queryId;
    }
    

提交回复
热议问题