MySQL 表存在于服务器上,但无法从 PHP 访问它 [英] MySQL table exists on server but cannot access it from PHP
问题描述
我使用 PHPMyAdmin 向数据库添加了一个新表;尝试从 PHP 页面访问它时,我收到可怕的 MySQL 错误表不存在".
数据库连接数据是可以的,它们是在同一个页面上面几行用来访问同一个数据库中的另一个表.如果我在 PHPMyAdmin 中执行 SHOW TABLES
,则会列出新表;如果我从 PHP 页面执行此操作,则新表不会出现在列表中.新表的引擎是 MyISAM,就像数据库中的所有其他表一样.我只能通过 PHPMyAdmin 访问数据库服务器.
I added to a database a new table using PHPMyAdmin; when trying to access it from a PHP page I get the dreaded MySQL error "table doesn't exist".
Database connection data are OK, they are used a few lines above on the same page to access another table in the same database. If I do SHOW TABLES
in PHPMyAdmin the new table is listed; if I do it from a PHP page the new table does not appear in the list.
Engine for the new table is MyISAM, like all other tables in the database. I can access the db server only via PHPMyAdmin.
对不起,我忘记了代码,这是:
Sorry, I forgot the code, here it is:
$db = mysql_connect ($db_host, $db_user, $db_password) or
die("Error message here");
$db_select = mysql_select_db($db_name, $db)or die("Error message here");
$query = ("SELECT * FROM `old_table`");
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
// do stuff - here it works
}
$query = ("SELECT * FROM `new_table`");
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
// do stuff - here it does not work
echo mysql_error();
}
推荐答案
在 Unix 上,表名区分大小写.在 Windows 上,它们不是.有趣,不是吗?有点像他们各自的文件系统.你认为这是巧合吗?
On Unix, table names are case sensitive. On Windows, they are not. Fun, isn't it? Kinda like their respective file systems. Do you think it's a coincidence?
这可能取决于表类型;MyISAM 在你的情况下.
It probably depends on table type; MyISAM in your case.
字段名称不区分大小写.
Field names are case-insensitive regardless.
对于数据库和表名,取决于底层操作系统.标识符区分大小写
For database and table names, it depends on the underlying operating system. Identifier Case Sensitivity
这篇关于MySQL 表存在于服务器上,但无法从 PHP 访问它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!