Setting up a new database

admin

Administrator
Staff member
I am rather new at PHP and I am having trouble setting up a database, it is a mysql script and my ISP supports mysql but I am unsure of what the error messages mean I have included both the error in the browser and the code I am using minus user name and password = )

Browser:
Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) in /www/htdocs/createdb.php on line 14

Warning: Supplied argument is not a valid MySQL-Link resource in /www/htdocs/createdb.php on line 15
The database, NewDatabase, could not be created!

Warning: Supplied argument is not a valid MySQL-Link resource in /www/htdocs/createdb.php on line 20

My Code:

<head>
<title>My First Database</title>
</head>

<body bgcolor="#FFFFFF" text="#000000">

<?php
$Host="localhost";
$User="superman";
$Password="crackers";
$DBName="NewDatabase";

$Link = mysql_connect ($Host, $User, $Password);
if (mysql_create_db ($DBName, $Link)) {
print("The Database, $DBName, was successfully created!<BR>\n");
} else {
print("The database, $DBName, could not be created!<BR>\n");
}
mysql_close($Link);
?>

</body>
 
Back
Top