致命错误:在 php 中调用未定义的函数 fetch_assoc() [英] Fatal error: Call to undefined function fetch_assoc() in php
本文介绍了致命错误:在 php 中调用未定义的函数 fetch_assoc()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到错误致命错误:调用未定义的函数 fetch_assoc()".你能告诉我应该如何进行吗?
I am getting an error "Fatal error: Call to undefined function fetch_assoc()". Can you please advise on how I should proceed?
代码如下
$servername = "localhost";
$username = "s";
$password = "j";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$sql = "select idnew_table, new_tablecol from new_schema.new_table;";
$result = $conn->query($sql);
$r = count($result);
if ($result['num_rows'] != 10) {
while($row = $result[fetch_assoc()]){
echo "id: " . $row["idnew_table"]. " - Name: " . $row["new_tablecol"];
}
} else {
echo "0 results";
}
$conn->close();
推荐答案
这一行:
while($row = $result[fetch_assoc()]){
应该是:
while($row = $result -> fetch_assoc()){
这篇关于致命错误:在 php 中调用未定义的函数 fetch_assoc()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文