2015-09-04 35 views
-1

我目前正在寫一個PHP腳本,但是我在使用過時的功能的問題..不推薦使用:功能mysql_numrows()被棄用

可能有人請解釋我是如何從被棄用停止這些功能或如何改變他們到當前的:

function calcNumActiveGuests(){ 
     /* Calculate number of guests at site */ 
     $q = "SELECT * FROM ".TBL_ACTIVE_GUESTS; 
     $result = mysql_query($q, $this->connection); 
     **$this->num_active_guests = mysql_numrows($result);** 
    } 

function calcNumActiveUsers(){ 
     /* Calculate number of users at site */ 
     $q = "SELECT * FROM ".TBL_ACTIVE_USERS; 
     $result = mysql_query($q, $this->connection); 
     **$this->num_active_users = mysql_numrows($result);** 
    } 

他們現在給我的錯誤Deprecated: Function mysql_numrows() is deprecated

+2

可能重複的[MySQL的\ _num \ _rows replacment到建議更換?](http://stackoverflow.com/questions/20396858/mysql-num-rows-replacment-to-recomend) – moonwave99

+0

我讀過那篇文章,但對我來說它沒有意義的答案,所以我創建了這個與我的代碼 – AppStash

+0

到s從棄用的功能開始,您將需要一臺時間機器。 – Rasclatt

回答

1

你不能阻止被廢棄的函數(當然,除非你的名字是Rasmus Lerdorf)。

函數由於許多原因而被棄用,並且建議您理解原因。如果您訪問PHP頁面並查找給予您警告的功能,它通常會建議您採取何種操作。例如:mysql_num_rows()

此擴展在PHP 5.5.0中已棄用,並且已在PHP 7.0.0中刪除。相反,應該使用MySQLiPDO_MySQL擴展名。另請參閱MySQL: choosing an API指南和related FAQ的 更多信息。替代這個功能包括:

相關問題