Php mysql connect

Reply

Join Date: Sep 2008
Posts: 138
Reputation: rajeesh_rsn is an unknown quantity at this point 
Solved Threads: 0
rajeesh_rsn rajeesh_rsn is offline Offline
Junior Poster

Php mysql connect

 
0
  #1
Sep 27th, 2009
Hai friends,
I had a main web site and a number of 15 ( also increasing ) child websites. I had a master database in my main website. Now I need to connect main database from the child websites. I had a code to connect the database from main website that is...

mysql_connect("localhost", "user_name","password") or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());

I tried this code on child website. But access denied error showing. I already set all privileges to the above user . I tried this code


mysql_connect("mydomain.com", "user_name","password") or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());

I also tried www.mydomain.com, http://mydomain.com, ip address of my domain insted of "localhost" . But cant connect...


Please give me a help in the above problem.
Thanks in advance
Rajeesh
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 26
Reputation: farhan386 is an unknown quantity at this point 
Solved Threads: 3
farhan386's Avatar
farhan386 farhan386 is offline Offline
Light Poster

Re: Php mysql connect

 
0
  #2
Sep 27th, 2009
Do you use shared web hosting?
Most shared hosting limit mysql connection from localhost only due to security reason. You cant connect to mysql on a shared hosting from different host.

Ask your hosting provider whether they provide "Remote MySQL", or move all of your website to one single server.
I'm spammer...
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 138
Reputation: rajeesh_rsn is an unknown quantity at this point 
Solved Threads: 0
rajeesh_rsn rajeesh_rsn is offline Offline
Junior Poster

Re: Php mysql connect

 
0
  #3
Sep 27th, 2009
Thanks for your kind advice.
I solved the problem using Remote MySQL, as you said i just added my host name in to remote mysql like XXX.XX.XXX.%.

If you don't mind please let me know for what "%" is using. Is there is any security issue if I enable remote MySQL

Once again thanks for your support
Rajeesh




Originally Posted by farhan386 View Post
Do you use shared web hosting?
Most shared hosting limit mysql connection from localhost only due to security reason. You cant connect to mysql on a shared hosting from different host.

Ask your hosting provider whether they provide "Remote MySQL", or move all of your website to one single server.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 26
Reputation: farhan386 is an unknown quantity at this point 
Solved Threads: 3
farhan386's Avatar
farhan386 farhan386 is offline Offline
Light Poster

Re: Php mysql connect

 
0
  #4
Sep 27th, 2009
% mean "from any host"

user1@localhost mean "user1 who came from localhost only"
user1@% mean "user1 who came from anywhere"

disabling remote mysql is the safest option, since you can sure that only script resides on your own server are allowed to access your database.

By enabling remote mysql with wildcard (the %), your database can be accessed (and of course, brute forced) from anywhere.
I'm spammer...
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 138
Reputation: rajeesh_rsn is an unknown quantity at this point 
Solved Threads: 0
rajeesh_rsn rajeesh_rsn is offline Offline
Junior Poster

Re: Php mysql connect

 
0
  #5
Sep 28th, 2009
Thank you for your kind information
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC