MySQL Forums
Forum List  »  General

MySQL - selecting wrong DB
Posted by: Igor Felipe
Date: November 25, 2004 06:14AM

What is the nature of the problem?
Very weird!
MySQL is selecting the wrong DB.
In the connection script I ask for "fisi_propria" database and it connects... but when I select a table from this database it tells me that this table doesn't exist, BUT IN ANOTHER DATABASE wich is "fisi_fisiculturismo" and was not selected.

What is the error message?
Table 'fisi_fisiculturismo.fisi_artigos' doesn't exist
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/............... on line 68

BUT TABLE fisi_artigos is in fisi_propria database, the one that was selected in the connection function.

Was it working before?
Yes, but the database "fisi_fisiculturismo" was getting so huge that I decide to create another database, "fisi_propria" to hold some tables... make easy to back up and etc.

If it was working before, did you do anything before this error occurred?
Yes, created another database and replaced some tables to the new one.

Have you done anything after this error occurred?
Yes, check for errors in all databases and tables, tried changing name of the new database, created new users to access the database... but nothing worked.
It's a very strange error.

Here is my SCRIPT to connect:
=============
<?
//conexao.php

$dbhost = 'localhost';
$dbusername = 'USERNAME';
$dbpassword = 'PASSWORD';
$default_dbname = 'fisi_propria';

$conexao = mysql_connect($dbhost, $dbusername, $dbpassword);
if(!$conexao) {

echo '<p><big><big><big>Não foi possível estabelecer uma conexão com o banco de dados.<br>';
echo 'Provavelmente o número de conexões simultâneas foi superior ao suportado pelo servidor.<br>';
echo 'Favor tentar novamente mais tarde.<br><br>';
echo '<b>Equipe Fisiculturismo.com.br</b></p>';

exit;
}
$selecionar_db = mysql_select_db($default_dbname);
if(!$selecionar_db) {

echo '<p>Não foi possível selecionar o banco de dados.</p>';
echo '<p>Provavelmente o número de conexões simultâneas foi superior ao suportado pelo servidor.</p>';
echo '<p>Favor tentar novamente mais tarde.</p>';
echo '<p><b>Equipe Fisiculturismo.com.br</b></p>';

exit;
}

?>
=============

As you can see, I select "fisi_propria" database, but the mysql look for the table in "fisi_fisiculturismo" database...

It is important to mention that user "USENAME" is the only one who has permission to acess "fisi_propria".

Options: ReplyQuote


Subject
Written By
Posted
MySQL - selecting wrong DB
November 25, 2004 06:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.