Help connecting PHP to SQL

Messages
1
Reaction score
0
Points
0
Hi,

I keep getting an access denied error when I try to connect my php file to the MySQL database. Here is my connection code, please tell me what I am doing wrong.

$dbhost = 'localhost';
$dbuser = 'search';
$dbpass = '1Search2';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'shellyb_dbFamily1';
mysql_select_db($dbname);

Thanks
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
What's the exact error message?

DB usernames on X10 begin with your cPanel user name, e.g. shellyb_search. "search" is wrong for a DB username.

Make sure you add the DB username to the 'shellyb_dbFamily1' database so it has access.

Before asking a question, search the forum and the web at large for your error message. If it's a basic question, it's been asked before.

Don't put your password in posts; use '***' or similar. Edit the post right now and change the p/w in cPanel.

Don't use "or die()" in production code.

The MySQL driver is outdated. Use MySQLi or (better yet) PDO.
 
Last edited:
Top