PHP mysqli 返回错误的列

标签 php mysql mysqli

我正在编写一个需要使用 MySql 的简单 PHP cgi 程序。我从玩家表中的两列开始,我的 SELECT 工作正常。从那时起,我又添加了另一列,称为 class_id。当我现在执行 SELECT 时,我在 $row 中得到三个条目,但第三个条目被称为 players 而不是 class_id。

$sql = "SELECT * FROM players";
$result = $conn->query($sql);
while( $row = $result->fetch_assoc() ){
  do something
}

架构:

DROP TABLE IF EXISTS `asrleague`.`players`;
CREATE TABLE  `asrleague`.`players` (
  `player_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `kgs_handle` varchar(40) NOT NULL,
  `class_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`player_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

PHP 是否在某处缓存了有关表的信息,我需要以某种方式刷新它?

我也看到了这个警告,它一直存在:

<b>Warning</b>:  mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: Headers and client library minor version mismatch. Headers:50145 Library:50018 in ...

我不确定这是否相关,但在问题开始之前就已经存在了。

最佳答案

一些谷歌搜索你的错误信息,给出了那些有趣的线程:

似乎需要重新安装 PHP。

从第一个链接(粗体来 self )引用一个答案(anishmsry 的):

Hi bmcgill... i had installed php, mysql and apache some months ago in my computer following the instructions from kevin's book. and there was no problem. everything was working fine.

i bought a new computer last week and installed the latest versions in the new computer. after installing and running it. i got the error which u got: Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50145

i reinstalled everything and again i was receiving the same error. i had the same conf for mysql, php and apache as u've mentioned.

i uninstalled apache and php. and installed the earlier versions which i was using: apache- 2.2.11 and php-5.3.0. this time everything was working fine and there was no error

well it just worked like that for me. that's why i'm telling. i don't know why it worked now.

i was searching about this issue in net, and in a forum in mysql's website i found that some other person had this problem with a much earlier versions. he reinstalled php and the problem was solved.

关于PHP mysqli 返回错误的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5566406/

相关文章:

PHP方法存在于类中而不创建对象

mysql - 从列表中获取 float

php - 使用for循环和mysql更新数据库

php - MySQL - 在每行中存储引用数组

php - 从数据库检索图像并更新图像或上传另一个文件

php - 在 PHP 中更新 MYSQL 表

php - 无法在 php 中使用 mysqli 创建刚刚插入的记录的数组

php - 无法显示 MySQL 表中的数据

php - 如何将 mysqli 结果转换为 JSON?

php - 当我尝试使用 php 文件时,ffmpeg 显示 null