Can't connect to MySQL server by php code

Status
Not open for further replies.

beamblues50

New Member
Messages
7
Reaction score
0
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,
 

descalzo

Grim Squeaker
Community Support
Messages
9,375
Reaction score
327
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?
 

beamblues50

New Member
Messages
7
Reaction score
0
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?
 

descalzo

Grim Squeaker
Community Support
Messages
9,375
Reaction score
327
Points
83
cPanel --> MySQL Databases
When you add a DB user to a DB, a screen pops up and you must check ALL_PRIVILEGES
 

beamblues50

New Member
Messages
7
Reaction score
0
Points
0
I have just created two new users. In no one I saw something with this for check this option..:confused:
 

beamblues50

New Member
Messages
7
Reaction score
0
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:
 

gomarc

Member
Messages
516
Reaction score
18
Points
18
Hi beamblues50,

If you are using MySQL® Databases (not the Wizard)
oggfp0.jpg



At the bottom of the page, do you have the “Add User To Database”?
2e0lc10.jpg


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

beamblues50

New Member
Messages
7
Reaction score
0
Points
0
Hi beamblues50,

If you are using MySQL® Databases (not the Wizard)
oggfp0.jpg



At the bottom of the page, do you have the “Add User To Database”?
2e0lc10.jpg


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


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.
 
Status
Not open for further replies.
Top