This is the code I have below can anyone tell me why it's not connecting to the servier.

<html>
<head>
<title>Connecting to MYSQL</title>
</head>
<body>
<?php
$connect = mysql_connect("127.0.0.1","","") or die(mysql_error());;
if ($connect != FALSE)
{
print "The connection was a success";
}
else
{
print "The connection was a failure";
}

mysql_close($connect);
?>
</body>
</html>

    your syntax looks right, except for the 2 semicolons at the end of this line:

    $connect = mysql_connect("127.0.0.1","","") or die(mysql_error());;
    

    there should only be 1 semi-colon at the end.

    as for connecting, is mysql expecting a username? if it is, then you need to specify one.

    what does mysql_error return when the connection fails??

    I don't know if this should matter, but try using localhost instead of 127.0.0.1

    • keith

      This is not meant as a thread abduction, if it sounds like it might be please let me know and I'll repost. The question ...
      Is there any performance benifit of using the actual IP address rather than the domain name on a Linux box? The train of thought I'm on is that the comp's going to have to check in /etc/hosts even for localhost, or is this too trivial to worry about?

        Keith,
        I thought if the MYSQL and Web server is running on the same computer I should be able to just use the 'localhost'. I changed the code to what's below. Do you see anymore problems with it or do you know of anything else I could read to help me out. The error that I'm recieving is below.

        </head>
        <body>
        <?php
        $connect = mysql_connect("localhost",'sun','sun1') or die(mysql_error());
        if ($connect != FALSE)
        {
        print "The connection was a success";
        }
        else
        {
        print "The connection was a failure";
        }

        mysql_close($connect);
        ?>
        </body>
        </html>

        Query Failed

        2003: Can't connect to MySQL server on 'localhost' (10061)

          Write a Reply...