Can't connect to MySQL server by php code

Discussion in 'Free Hosting' started by beamblues50, Oct 17, 2011.

Thread Status:
Not open for further replies.
  1. beamblues50

    beamblues50 New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Hi. I have created a database and a user with their respective password. In my php code I have:

    $link = mysql_connect('localhost', 'my_user_name', 'my_password');
    if (!$link) {exit;}
    echo 'Connected successfully<br>';
    $db_selected = mysql_select_db('my_database_name', $link);
    if (!$db_selected) {
    die (mysql_error());}

    Then the result is:

    Connected successfully
    Access denied for user 'my_user_name'@'localhost' to database 'my_database_name'

    I'll tried add in cPanel Remote Database: 69.175.6.94, init.fris.x10hosting.com, and stoli.x10hosting.com, without improvement. The strangle is that by MyPHPadmin I can access and create/alter tables. Somebody can help me?

    Thanks,
     
  2. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    Exactly what is the db name? Are you sure it is correct? Did you add the DB user to the DB with all privileges?
     
  3. beamblues50

    beamblues50 New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    My database is "marnel_sd". In the cPanel icon MySQL databases, I didn't discovered the options for the setting privileges; where are there?
     
  4. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    cPanel --> MySQL Databases
    When you add a DB user to a DB, a screen pops up and you must check ALL_PRIVILEGES
     
  5. beamblues50

    beamblues50 New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    I have just created two new users. In no one I saw something with this for check this option..:confused:
     
  6. Dead-i

    Dead-i x10Hosting Support Ninja Community Support

    Messages:
    6,084
    Likes Received:
    367
    Trophy Points:
    83
    Last edited: Oct 17, 2011
  7. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    Not when you create it.
     
  8. beamblues50

    beamblues50 New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Very extrangle. I have created other new user, this time using the Internet Explorer and not the Firefox. And again also never appear the options for ALL PRIVILEGES. Am I making a mistake in something??:confused:
     
  9. gomarc

    gomarc Member

    Messages:
    516
    Likes Received:
    18
    Trophy Points:
    18
    Hi beamblues50,

    If you are using MySQL® Databases (not the Wizard)
    [​IMG]


    At the bottom of the page, do you have the “Add User To Database”?
    [​IMG]

    You need to click on the Add button to set the privileges, as descalzo pointed out.
     
  10. beamblues50

    beamblues50 New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0

    It's seems that already yet working!! Thanks you very much:)

    ---------- Post added at 05:34 PM ---------- Previous post was at 05:33 PM ----------

    It's seems that already yet working!! Thanks you very much.
     
Thread Status:
Not open for further replies.

Share This Page