SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php connection problem

    I have logged in and created the database needed and have gave my user all of the permissions. But my install.php that i created still doesn't work and it gives this error:
    Code:
    Access denied for user: 'kyhxneta_kyhx@localhost' to database 'kyhxblog'

    my code is as followed:
    Code:
    <?php
    // CONFIG.PHP
    // Confifure you db connection here
    
    $dbhost = 'localhost';
    $dbname = 'kyhxneta_kyhxblog';
    
    $dbuser = 'kyhxneta_kyhx';
    
    $dbpass = '*****';
    
    
    
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    
    ?>
    
    <?php
    // INSTALL.php
    require 'config.php';
    
    // Create table in kyhxblog database
    
    mysql_select_db($dbname, $conn)
    
    $sql = "CREATE TABLE post 
    
    (
    
    post_id MEDIUMINT NOT NULL AUTO_INCREMENT,
    
    post_title VARCHAR(50),
    
    post_date DATE,
    
    Post_body LONGVARCHAR,
    
    PRIMARY KEY (post_id)
    
    )";
    
    mysql_query($sql,$conn);
    
    
    
    mysql_close($conn);
    
    ?>
    I cant figure out why I can't create a new table for a database that i have set all the permissions allowed for my user that i connect with. If anyone could lend their wisdom i would greatly appreciate it.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    no db cnx

    Are you certain the value for host is "localhost"? Some servers use different values.

  3. #3
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,098
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    sometimes db uses something like yourdomain_kyhxblog when db is created, I go through stuff like this everytime I work with different hosts.

    whats missing from your error is:

    using password yes / no

    it might be a clue
    What I lack in acuracy I make up for in misteaks

  4. #4
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It simply looks as if you don't have the permission to access the database. Contact your host, or carefully check in your control panel if you have added the user on that particular database.

  5. #5
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know for a fact that it is localhost, due to my old site on the same server and checking the configuration of them to being set to the same thing... thank you though for the reply. i have seen the "using password" before, but that was fixed with a change of user name.

    i believe that the permissions for the database are excessively open. I made sure it had ever option available to the user i would be using.

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    It might be due to not having the correct privaledges which is different from permissions.

    On the shared hosting I use I get a certain number of databases but cannot create any more. Check with your host to see the state of play.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •