亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

MYSQL_NUM 不能用在 mysqli_fetch_array上

如題, 加了 這個第二個參數,報錯。

while($row=mysqli_fetch_array($res,MYSQL_NUM)){
print_r($row);
}


正在回答

3 回答

看看手冊咯

mixed ?mysqli_fetch_array ?? ?( mysqli_result ?$result ?? [, int $resulttype ?= MYSQLI_BOTH ??] )

resulttype

This optional parameter is a constant indicating what type of array ? ? ? should be produced from the current row data. The possible values for ? ? ? this parameter are the constants MYSQLI_ASSOC , ? ? ? ?MYSQLI_NUM , or MYSQLI_BOTH .?

用MYSQLI_NUM就行了

0 回復 有任何疑惑可以回復我~

<?php
header("Content-type:text/html;charset=utf-8");
$host='localhost';
$user='g';
$password='yz';
$con = mysqli_connect($host, $user, $password);
mysqli_select_db($con, 'abc');
mysqli_query($con, "set names 'utf8'");
$res = mysqli_query($con,'SELECT * FROM subjects');
while($row=mysqli_fetch_array($res,MYSQL_NUM)){
print_r($row);
}
?>

0 回復 有任何疑惑可以回復我~

不知道你其他的代碼是這么寫的 貼出看看可以嗎?

還是說逗號你打的是中文的?

0 回復 有任何疑惑可以回復我~
#1

慕粉3296411 提問者

代碼在我自己的回答中,底下是其報的錯 Notice: Undefined variable: res,MYSQL_NUM in /Library/WebServer/Documents/html/mysql_prac.php on line 13 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /Library/WebServer/Documents/html/mysql_prac.php on line 13
2016-08-01 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
PHP與MySQL關系大揭秘
  • 參與學習       72509    人
  • 解答問題       978    個

讓我們一起走上探秘之旅,找尋php和mysql戀愛的真諦

進入課程

MYSQL_NUM 不能用在 mysqli_fetch_array上

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號