+ Reply to Thread
Results 1 to 8 of 8
Like Tree2Likes
  • 1 Post By sharper
  • 1 Post By garrettroyce

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

  1. #1
    sharper is offline x10Hosting Member sharper is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    10

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

    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:

  2. #2
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

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

    Change
    mysql_select_db("sharper_allegiance", $con);
    to
    mysql_select_db("sharper_allegiance");

  3. #3
    sharper is offline x10Hosting Member sharper is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    10

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

    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?

  4. #4
    monpire is offline x10Hosting Member monpire is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    16

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

    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

  5. #5
    sharper is offline x10Hosting Member sharper is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    10

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

    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:
    karimirt47 likes this.

  6. #6
    ichwar's Avatar
    ichwar is offline Community Advocate ichwar is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    NC, USA
    Posts
    1,454

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

    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 ());

  7. #7
    sharper is offline x10Hosting Member sharper is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    10

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

    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:?

  8. #8
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

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

    You can't close your own threads in this forum

    It's a good thought though.
    dinomirt96 likes this.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

+ Reply to Thread

Similar Threads

  1. Any good PHP/MySQL tutorials out there?
    By shiveringtim in forum Off Topic
    Replies: 4
    Last Post: 05-13-2008, 10:34 PM
  2. newbie here
    By sabasusu in forum Free Hosting
    Replies: 1
    Last Post: 03-23-2008, 10:17 AM
  3. Any advice for a newbie?
    By adugan86 in forum Introductions
    Replies: 4
    Last Post: 01-08-2008, 02:32 PM
  4. Newbie question: Browser can't access database
    By eN0ch in forum Free Hosting
    Replies: 3
    Last Post: 10-24-2007, 01:40 AM
  5. Hello X10 Forum !! I'm a new newbie !!!
    By Darie in forum Introductions
    Replies: 4
    Last Post: 10-17-2007, 10:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers