PHP mysqli返回错误的列 [英] PHP mysqli returns wrong columns

查看:52
本文介绍了PHP mysqli返回错误的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个需要使用MySql的简单PHP cgi程序.我从玩家表中的两列开始,而我的SELECT正常运行.从那以后,我添加了另一列,称为class_id.现在执行SELECT时,我在$ row中返回了三个条目,但是第三个条目称为玩家而不是class_id.

I'm writing a simple PHP cgi program that needs to use MySql. I started with two columns in the players table, and my SELECT worked fine. I have added another column since then called class_id. When I do a SELECT now, I get three entries back in $row, but the third entry is called players instead of 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是否在某处缓存了有关该表的信息,我需要以某种方式刷新它吗?

Is PHP caching info about the table somewhere, and I need to get it to refresh somehow?

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

I'm also seeing this warning, which has been there all the time:

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

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

I'm not sure if that's related or not, but it was there before the problem started.

推荐答案

对您的错误消息进行一些谷歌搜索,给出了那些有趣的线程:

Some Googling on your error message, gives those interesting threads:

  • http://www.sitepoint.com/forums/php-34/just-starting-loading-php-ini-664446.html
  • http://forums.mysql.com/read.php?52,290016,290016#msg-290016

似乎有必要重新安装PHP.

Seems that a reinstallation of PHP could be necessary.

从第一个链接(答案是我的粗体)中引出答案(西文):

Quoting an answer (anishmsry's) from the first link (bold is from me):

bmcgill ...我已经安装了php, mysql和apache几个月前在我的 按照说明操作计算机 摘自凯文的书.而且没有 问题.一切都很好.

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.

我上周买了一台新电脑, 在 新电脑.在安装和 运行它.我得到了你的错误 得到了:警告:mysqli_connect() [function.mysqli-connect]:标题和 客户端库次版本不匹配. 标头:50051库:50145

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

我一遍又一遍地重新安装了所有软件 收到相同的错误.我有 对于mysql,php和相同的conf 就像你提到的那样.

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.

我卸载了Apache和php.和 我安装了较早的版本 使用的是:apache- 2.2.11和 php-5.3.0.这次一切都是 工作正常,没有错误

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.

我正在搜索有关此问题的信息 网络,并在mysql网站的论坛中 我发现其他人有 这个问题要早得多 版本.他重新安装了PHP和 问题解决了.

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返回错误的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆