MySql 查询不在 PHP 中工作,但在 phpMyAdmin 中工作 [英] MySql query not in working in PHP but works in phpMyAdmin
问题描述
起初我很抱歉发布重复的问题,我总是试图找到答案,从不问.但没有什么能解决我的问题.我有一个名为 data
的表的 MySql 数据库.我无法更改表名.当我在 phpMyAdmin 中执行 SELECT * FROM `data`
或 SELECT * FROM data
时,查询工作正常,但是当我在 PHP 脚本中执行它时,query()
返回 false
At first I'm sorry for posting duplicate question I always try to find answers and never to ask. But nothing solved my problem. I have a MySql DB with table named data
. I cannot change the table name. When I execute SELECT * FROM `data`
or SELECT * FROM data
in phpMyAdmin, the query works correctly but when I execute it in PHP script the query()
returns false
<?php
$conn = new mysqli('localhost', 'username', 'pswd', 'dbname');
if ($conn->connect_error) {
die('connection error');
}
$result = $conn->query("SELECT * FROM `data`");
var_dump($result);
echo "-".$conn->error."-";
我看过这些问题:
Mysql 查询在 phpmyadmin 中有效但不是在 php 中(由于日期)
Mysql 查询适用于 Phpmyadmin 但不适用于PHP
MySQL 查询在 phpmyadmin 中工作但在 php 中无效一个>
还有其他一些...
推荐答案
通过您的回复,我知道下一步该尝试什么了.我在自己的服务器上创建了表的副本并尝试更改数据类型.原始表中的一种数据类型设置为 JSON,当我将其更改为 TEXT 时它开始工作.
With your replies I've got some idea what to try next.I've created copy of the table on my own server and tried changing data types. One of data types in original table is set as JSON, when i changed it to TEXT it started to work.
这篇关于MySql 查询不在 PHP 中工作,但在 phpMyAdmin 中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!