4

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();
}
3
  • 2
    Is the PHP script connecting with the same user as you are connecting via PMA? The user may not have access to the table. Commented Jan 19, 2013 at 13:57
  • try running "SHOW TABLES" from PHP and check if the new table is listed Commented Jan 19, 2013 at 14:20
  • No, it does not appear in the list. Commented Jan 19, 2013 at 14:24

3 Answers 3

4

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?

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

Sign up to request clarification or add additional context in comments.

1 Comment

check whether the table names are correct and they are not mistakenly typed
2

The answer is simple: some typo or another silly mistake like this: you're connecting wrong server, editing wrong file or something of the kind. Just double check everything.
There is no particular error to cause this

1 Comment

You are right: there is no reason for this. I am checking again everything but can't find anything wrong.
1

The answer is: the table name or at least one of the field names is a reserved word.

To solve it, you can enclose the fields and table name with grave accents (`), e.g:

SELECT `value` FROM `pivot`;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.