Not connecting to MySQL

Status
Not open for further replies.

jcarlin14

New Member
Messages
3
Reaction score
0
Points
0
I am using code that I know works from previous pages I have developed, but for some reason the PHP won't connect to the DB and I am getting a "No database selected" error.

My coding is:

mysql_connect("localhost","user","password") or die ('Error: ' . mysql_error());
mysql_select_db ("name of database");

Is there a special naming format for the database?
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Database is prefixed by your cpanel name, so if you originally told it to name it forum, it's now cpanelnamegoeshere_forum.

That prevents all the users who have "forum" as a database from interfering with each other :)


That said I peeked on the server and you actually have it right, so I'd say do mysql_select_db ("name of database")or die ('Error@2: ' . mysql_error());

That way you'll be able to see the error being returned from the select_db command.
 
Status
Not open for further replies.
Top