PHP can't connect to MySQL server 
Author Message
 PHP can't connect to MySQL server


Try this:

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_Fund = "ipaddress";
$database_Fund = "dbname";
$username_Fund = "username";
$password_Fund = "password";
$datasourcename = mysql_pconnect($hostname_datasourcename,
$username_datasourcename, $password_datasourcename) or die(mysql_error());

> I'm probably doing something dopey, but I can't work out what.

> PHP 4.3.0 is installed, and Apache 1.3.27 (running under W2K) will
> serve the test.php page with the call to phpinfo().
> MySQL 3.23.54-max  is installed, and I can use the command-line
> utility to talk with it, create dbs etc.

> But PHP can't connect to the MySQL server, and the error message
> ('Can't connect to MySQL server on 'localhost' (10061)') isn't
> especially helpful.  My test code seems unobjectionable:

>     $svr = mysql_connect( "localhost", "", "" ) ;
>     if ( !empty( $svr ))
>     {
>         echo "Connected";
>     }
>     else
>     {
>         echo "Couldn't connect";
>     }

> Any insights greatly appreciated.

> Margaret
> --
> (To mail me, please change .not.invalid to .net, first.
> Apologies for the inconvenience.)

Posted Via = SPEED+RETENTION+COMPLETION = http://www.*-*-*.com/

Tue, 30 Aug 2005 00:43:26 GMT  
 PHP can't connect to MySQL server


> I think my copy of PHP must be a little bit broken, somehow.  When,
> just for a giggle, I replaced 'localhost' with the nodename of my
> system, it worked.  But Apache has no trouble figuring out who
> localhost is, so it's not a system-wide problem.  hmmmm....

this has nothing to do with your php installation. sounds to me
as if mysql is only listening for connections on the interface
(ip address) tied to its hostname, not on the loopback (localhost)

you can confirm this with the netstat command in a shell. start
cmd and execute 'netstat -n' (no quotes) and look for lines in the
LISTEN state. a local address of means it's listening on
all interfaces, means it's listening only on the loopback
interface (localhost) and your ip ( if you are posting
from the development box) means it's only listening on the interface
tied to it's ethernet interface.

if i'm right, and you want to change this, you'll have to do so in
the mysql configuration (not that i see any reason to, now that you
got it working :-)


--                                         fax:+47 33313846
E9D4 D43C A6AE 80D8 98C8 878F A288 AC53 230E 1658      mob:+47 97152009

Tue, 30 Aug 2005 12:04:45 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Php 4.2.3 with Apache 2 don't connect with Mysql

2. PHP - MYSQL Connect with --local-infile=1

3. Connecting to mySQL on Unix server

4. Using remote MySQL server with PHP via HTTP

5. MySQL/PHP with redundant slave servers

6. PHP, MYSQL, IIS5 and Win2k Server in a Corporate Environment

7. SQL Server to MySQL thru PHP

8. New mysql user can't connect

9. Using CGI module with 'canned queries'

10. php mysql sample code php shareware like KB knowledgebase

11. PHP+MySQL vs. PHP+PostgreSQL

12. php + mysql or php + postgresql?


Powered by phpBB® Forum Software