Can connect to one database but not the other

Status
Not open for further replies.

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
When I go onto one of my websites, it connects just fine, no problems at all, the other one cannot connect at all. YET, when I go into the MySQL section of my cPanel it shows both's size = 0.0. When I go into PHPmyadmin it says I have 6 tables inside the one I cannot connect to on the left but when I go in it says No tables in this database.

Also when I went into the cPanel MySQL section and clicked Repair DB, it shows a page that says Table.tablename does not exist for each, but it can see that they are there... What is up?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Exactly what is the error message you get?
Are you sure that you assigned the user to the second database and gave it all permissions?
 

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
The error message is just:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sikuneh/public_html/inc/m.php on line 16

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sikuneh/public_html/inc/m.php on line 21

And yes I am sure I gave the permissions, otherwise it could not connect to the DB at all.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
The error message is just:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sikuneh/public_html/inc/m.php on line 16

l.

This means that the result you got back from mySQL is not a 'result', ie you got an error in your SELECT statement.

If you post the code from m.php (up to line 16), maybe we can find the problem or suggest code to add to narrow the possibilities.
 

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
Here is all the important code:
$rowsPerPage = 20;
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query = "SELECT * FROM submissions ORDER BY id DESC LIMIT $offset,$rowsPerPage";
$result = mysql_query($query);# or die("There was an error with the query.");

$rowcount = mysql_num_rows($result);

Information: Database connection already established, offset = 0 for now,

The reason it returns the error is because there is nothing to retrieve in the database and thus the tables in the database are invisible
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
PHP:
$query = "SELECT * FROM submissions ORDER BY id DESC LIMIT $offset,$rowsPerPage";
$result = mysql_query($query);# or die("There was an error with the query.");

#### debugging code
if( ! $result ){
  echo "Error in the query.<br />" ;
  echo mysql_error() ;
  die( "leaving now..." ) ;
}

$rowcount = mysql_num_rows($result);
 

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
Which returns what my original theory was:
Table 'sikuneh_stbnl.submissions' doesn't exist; leaving now...

Also a question:
Can you write into a log file using the fwrite() method within a die() method?
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Which means you never created the table. It is not 'invisible', it does not exist.
 

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
Please explain why then, that it is, that when I go into the repair DB section it shows they it can see them but it says it does not exist.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
You have two databases.
Are you sure you are looking at sikuneh_stbnl when you are using phpMyAdmin ?
 

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
Yes I am sure I am checking. Attached is an exact picture of what I see on PHPmyadmin. Highlighted points of interest.

Sorry for the crude drawing
 

Attachments

  • SQL_phpmyadmin_3-&#.jpg
    SQL_phpmyadmin_3-&#.jpg
    32.8 KB · Views: 23
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
It says the table does not exist. Which is what I said.

What am I missing?
 

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
If you notice the top left highlighted area it points out I have 6 tables in stbnl _stbnl(6). That is confusing me. And obviously I have more than just that one table. It seems to have been missing for a week or two.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Now I see what you are talking about.
One part of the system thinks there are tables in the db and another thinks there is none.

Did you ever create the tables?
One solution would be to drop the database and then create it again. I don't know of any other way of reconciling the two. Or you could try to manually create the tables in the DB, but I have a feeling that you might get an error (table already exists).
 

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
Yes, that was what I was going for. I guess I could try that.

Thanks
 
Status
Not open for further replies.
Top