Php 如何连接到XAMPP服务器?我得到的错误是致命错误:数组回调必须包含索引0和1
我在说一个错误 致命错误:数组回调中必须包含索引0和1 第10行的C:\xampp\htdocs\series\databases\index.php 这是我的小代码。我知道我实际上并没有从数据库中提取任何内容,但在解决此问题之前,我无法再进一步Php 如何连接到XAMPP服务器?我得到的错误是致命错误:数组回调必须包含索引0和1,php,mysql,database,xampp,Php,Mysql,Database,Xampp,我在说一个错误 致命错误:数组回调中必须包含索引0和1 第10行的C:\xampp\htdocs\series\databases\index.php 这是我的小代码。我知道我实际上并没有从数据库中提取任何内容,但在解决此问题之前,我无法再进一步 <?php require 'connect.inc.php'; $query = "SELECT `food`, `calories` FROM `food` ORDER BY `id`"; //$query_run = mysql_que
<?php
require 'connect.inc.php';
$query = "SELECT `food`, `calories` FROM `food` ORDER BY `id`";
//$query_run = mysql_query($query);
if ($query_run = mysql_query($query)){
while ($query_row = mysql_fetch_assoc($query_run)) {
$food = $query_row('food'); //Fatal error message for this line
$calories = $query_row('calories'); //When I comment out line 10 this gives an error too
}
} else {
echo mysql_error();
}
?>
如果您想了解更多信息,请告诉我,我正在学习的教程可能已经过时了。是的,有什么办法解决这个问题吗?谢谢
$query_row['food'];
您使用了错误的方括号,方括号访问数组项。谢谢,我实际上已经解决了这个问题,忘了返回这里,但您肯定是对的!