Jump to content
xisto Community
Sign in to follow this  
iGuest

Error 1046: No Database Selected

Recommended Posts

Thanks Xisto for providing me with FREE hosting support. However, as I am facing this problem,so, I need your help.

 

Whenever, I want to access my site ( MySQL-PHP Based), I get the following error message:

 

Error 1046: No Database Selected.

 

 

My connection string looks like:

 

$link_id = mysql_connect("localhost", "my_new_db_user_name", "my_new_db_password");

 

if(!$link_id) if(!$link_id)  error_message(sql_error());

followed by:

 

$current_db= mysql_select_db($db_name,$link_id);

Please note that:

 

My website runs smoothly in my local server without any error . Configuration of my local server is :

Apache 1.3.27(WIN32)/PHP 5.0.4 MySQL Server 4.1

Obviously, I have changed my db_name,db_user_name and db_password in the connection string for the webserver.

 

 

Webserver Information:

 

MySQL version 4.0.26-standard

PHP version 4.4.1

 

Thanks in anticipation of your reply.

Regards,

Sid

Share this post


Link to post
Share on other sites

I think that error was caused owing to MySQL overload. I received a bunch of emails from the server monitoring script informing me of a prolonged MySQL outage today. I'd advise you to try once again and let me know. Although this isn't a regular issue - you'll face it from time to time (at least once in two weeks) as our free servers are always under tremendous load.

 

Another issue you have to keep in mind is that, any MySQL Db you create here, will be prefixed with your cPanel login username.

 

Thus, if your cPanel login is: mylogin - and you create a DB named, mydb - that actual name of your database will be, mylogin_mydb. You've to include THIS name when you're using the mysql_select_db() function.

 

The same goes for your MySQL DB Username too - even that is prefixed by your cPanel login.

Share this post


Link to post
Share on other sites

I have been trying to access my website since last night and every time it gives the same error.

However, I have no problem in logging into my cPanel and administer my Database.

I have already included the name like mylogin_mydb in mysql_select_db() function infact in the last night . But since then, it is not working. Would you mind looking into this matter, I mean..., if possible. I am waiting for your reply.

 

Regards,

Sid.

 

*EDIT*

Yes, now it is running smoothly and I can access my website. Probably, as you have pointed out, it was due to MYSQL overload. And once again, the cPanel is wonderful. Thanks.

 

Regards

Sid.

Edited by sid.calcutta (see edit history)

Share this post


Link to post
Share on other sites

You have the same statement twice in one code block

if(!$link_id) if(!$link_id)  error_message(sql_error());
try it with just one conditional statement

if(!$link_id) error_message(sql_error());

also do you have an error_message() function defined elsewhere? It is not a PHP function, the closet to what your code shows would be trigger_error(string error message[int error type])

Share this post


Link to post
Share on other sites

Yes, I have defined the function error_message() in a seperate file that stores all the connection information to my MySQL database . My source code was also correct. I copied it wrongfully here. Now I can access my website without making any change in the code. Probably, as pointed out earlier, it was due to MySQL overload.

However, thanks a lot for your reply.

Regards,

Sid

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.