PHP/MYSQL failures... newbie needs help please!!!

sharper

New Member
Messages
10
Reaction score
0
Points
0
After a few days of server problems and password authentication errors, that seems to have ironed itself out, however I am still having problems connecting to my very basic mysql db.

PROBLEM

The problem is now is that it doesn't find the table for some reason "Error: Table 'sharper_allegiance.people' doesn't exist" which is odd.

Here is the code, it should be correct, so why can it not find the table? The table 'people' does exist in the database 'sharper_allegiance'. Am I supposed to enable something within the table to specify its available to access?

Its a very basic table, two columns, one called Darklings, the other Protectors... I have given very basic attributes and utf8 (not clear on what I should assign as the collation but that seems to work).

Here is the code

$con = mysql_connect("localhost:3306","name","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("sharper_allegiance", $con);

$result = mysql_query('SELECT * FROM `people` LIMIT 0, 30 ') or die ('Error: '.mysql_error ());

Database error from here, it is able to log into the database here, but now it says there is no table when there is...

:bowdown:
 

VPmase

New Member
Messages
914
Reaction score
0
Points
0
Change
mysql_select_db("sharper_allegiance", $con);
to
mysql_select_db("sharper_allegiance");
 

sharper

New Member
Messages
10
Reaction score
0
Points
0
Thanks for your help, I tried that and it didn't work though


I am going to put down the entire script, incase anyone needs that to fully understand what I have done. 99% of the script is from w3 schools and I have done alot of reading on connecting to db's and I think I have got it nearly spot on.... but still that error: Error: Table 'sharper_allegiance.people' doesn't exist


<?php

$con = mysql_connect("localhost","name","password");

if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("sharper_allegiance", $con);

$result = mysql_query("SELECT * FROM people") or die ('Error: '.mysql_error ()); [FAILS HERE]

echo "<table border='1'>
<tr>
<th>Darklings</th>
<th>Protectors</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Darklings'] . "</td>";
echo "<td>" . $row['Protectors'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);
?>

I can verify my database and table exists... sharper_allegiance.people as I have checked the db several times... but no luck...

I have also emailed tech support, as I think it may have something to do with the server move?
 

monpire

New Member
Messages
16
Reaction score
0
Points
0
When you select the DB, try adding your username before the DB name. Like:


mysql_select_db("username_sharper_allegiance", $con);

Also add or die after to see what it says
 

sharper

New Member
Messages
10
Reaction score
0
Points
0
Hi Monpire

Thanks for the suggestion, I did try that on the off-chance it would work... but the user name is already on there anyway sharper_ so as I thought it didn't work. I did put a die/error on the login/connection and got Error: Access denied for user 'sharper_charper'@'localhost' to database 'sharper_sharper_allegiance'...

If I remove the double sharper_ I return to the original error Error: Table 'sharper_allegiance.people' doesn't exist. This appears to be telling me that I can access the database, it just cannot locate the actual table within!

Perhaps it may have something to do with the server transfer but no one is really making much of an effort to help me with this one in support.

:crying:
 

ichwar

Community Advocate
Community Support
Messages
1,454
Reaction score
7
Points
0
Change: $result = mysql_query('SELECT * FROM `people` LIMIT 0, 30 ') or die ('Error: '.mysql_error ());

to: $result = mysql_query('SELECT * FROM people LIMIT 0, 30 ') or die ('Error: '.mysql_error ());
 

sharper

New Member
Messages
10
Reaction score
0
Points
0
Dear Everyone, thanks so much for all your help. A tech support person ended up giving me the server address of the new server we are on and I logged into that and noticed the table was not in the database (somehow it must not have replicated). I recreated it and now its all working... fantastic! I thought I was going to pull my hair out!

You've all been great.

Now where do I close this thread :cool:?
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
You can't close your own threads in this forum :)

It's a good thought though.
 
Top