就我對Google和所有內容所做的搜索而言,它看起來像是一個很常見的問題,但似乎無法修復它。另外,我認爲我和其他人有不同的用法。 而且,經過大約3個小時的運氣,我在這裏張貼!mysqli_free_result():mysqli_result類的對象無法轉換爲字符串
function free_result(){ # LINE 48
$free = "SELECT SHOW DESCRIBE EXPLAIN"; # LINE 49
$free = explode(" ", $free); # LINE 50
$sql = $this->sql; # LINE 51
while(list($key, $value) = each($free)){ # LINE 52
if(preg_match("/\b".$value."\b/", $sql)){ # LINE 53
$result = $this->result; # LINE 54
if(!mysqli_free_result($result)){ # LINE 55
$this->errors("Invalid result: <b>{$result}</b>. Couldn't free result."); # LINE 56
} # LINE 57
} # LINE 58
} # LINE 59
} # LINE 60
# LINE 61
function query($sql){ # LINE 62
$this->query_id = mysqli_query($this->connection, $sql); # LINE 63
$this->result = mysqli_store_result($this->connection); # LINE 64
$this->sql = $sql; # LINE 65
if(!$this->query_id){ # LINE 66
$this->errors("Couldn't query: <b>{$sql}</b>"); # LINE 67
return 0; # LINE 68
} # LINE 69
$this->affected = mysqli_affected_rows($this->connection); # LINE 70
# LINE 71
return $this->query_id; # LINE 72
} # LINE 73
這些是我的數據庫類中的2個函數。但我認爲只有這2個才能解決問題。
所以,我recieving錯誤是:
"Warning: mysqli_free_result() expects parameter 1 to be mysqli_result,
boolean given in [file path]\database.class.php on line 55"
#followed by my database class error handling
"Invalid result: . Couldn't free result."
至於我對這個去理解,我覺得現在的問題是$結果變量(54行,64行),但因爲這是我對MySQLi的第一次冒險,所以我不太確定。
我希望你能理解這個問題,並且能夠提供幫助! 在此先感謝!
謝謝!完美的作品...再次證明簡單更好。呵呵。 – jolt 2010-07-16 02:21:20