I am currently studying the php tutorial and am having connection problems:

My webhost provides mySQL which I acess via telnet. I wish simply to access my database using the following php commands:

// Connect to the database server
$dbcnx = @mysql_connect("localhost", "root", "mypasswd"); if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit(); }
// Select the "mydatabase" database
if (! @mysql_select_db("mydatabase") ) {
echo( "<P>Unable to locate the database " .
"database at this time.</P>" );
exit(); }

I have tried a number of variations to connect (localhost, IP addresses etc) to access mySQL database without success. I have also tried entering false passwords and usernames to verify the error script.

When connecting to mySQL via telnet I use a username and password firstly to access telnet then another username,pswd to access mySQL.

Any suggestions?