53329 Posted October 31, 2007 Share Posted October 31, 2007 I tried the example here: http://ca3.php.net/function.mysql-connect <?php // we connect to example.com and port 3307 $link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); // we connect to localhost at port 3307 $link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); ?> I tried both the port it gave and my cpanel port (2082). The cpanel one took longer but yielded similar results. With port as 2082: Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '********.net' (4) in /home2/mark/public_html/test.php on line 3 Could not connect: Can't connect to MySQL server on '********.net' (4) With port as 3307: Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in /home2/mark/public_html/test.php on line 3 Could not connect: Lost connection to MySQL server during query Server info is as folows: Operating system: Linux Apache version:1.3.37 (Unix) PHP version:4.4.7 MySQL version:4.1.22-standard I'm thinking maybe I need to enable something? That or maybe my host has a problem with it. Or I'm not using the correct port. There is very very little information on this that I can find so any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/ Share on other sites More sharing options...
revraz Posted October 31, 2007 Share Posted October 31, 2007 Try without a port. You did change the username and password to the correct DB username and password right? Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382278 Share on other sites More sharing options...
DyslexicDog Posted October 31, 2007 Share Posted October 31, 2007 I've been able to get this running sucessfully I use the ip and no port. I didn't use the domain name. Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382284 Share on other sites More sharing options...
53329 Posted October 31, 2007 Author Share Posted October 31, 2007 Yeah I replaced the login info. I tried the IP with no port and got the error: Warning: mysql_connect() [function.mysql-connect]: Access denied for user '*****'@'server5.hostprestige.com' (using password: YES) in /home2/dan/public_html/test.php on line 3 Could not connect: Access denied for user '*****'@'server5.hostprestige.com' (using password: YES) Host Prestige is my host and the name of the server itself is server5 (according to my cpanel). Edit: and the same thing happens if I put in the domain with no port. Same error message. Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382291 Share on other sites More sharing options...
revraz Posted October 31, 2007 Share Posted October 31, 2007 It is what it is, Access Denied = bad username and/or password. But that is a better error message, at least now you are getting to the DB. Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382297 Share on other sites More sharing options...
53329 Posted October 31, 2007 Author Share Posted October 31, 2007 See the odd thing is that a localhost connection on that server with the same information works fine so I'm wondering if something is disabled.... Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382301 Share on other sites More sharing options...
revraz Posted October 31, 2007 Share Posted October 31, 2007 Is it the same webhost that has the DB and where you have your .php? Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382304 Share on other sites More sharing options...
53329 Posted November 1, 2007 Author Share Posted November 1, 2007 Yes it is. Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382532 Share on other sites More sharing options...
rajivgonsalves Posted November 1, 2007 Share Posted November 1, 2007 this has got to do with the mysql server settings read more at http://dev.mysql.com/doc/refman/5.0/en/adding-users.html you hostname has to exists for that username in the hosts table of the mysql database Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382596 Share on other sites More sharing options...
53329 Posted November 1, 2007 Author Share Posted November 1, 2007 Yeah I think you're right. This looks like its what the problem was. I'll try to decipher what all this means but given that this wasn't setup I'd say topic solved. Quote Link to comment https://forums.phpfreaks.com/topic/75562-solved-non-localhost-connect/#findComment-382920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.