Click to See Complete Forum and Search --> : Help rookie learning


kproc
04-08-2006, 08:52 AM
below is code that I have found by seaching google and I made a few changes to (db name, server) top match my web server provider.

It give me a message "Couldn't connect to MySQL" Which tells me ????
I beleive that it has something to do with tryingto call the data base, AS I have been able to connect with the information shown below ( for obvious reasons the password is not correct)



thank you


<html><head><title>Birthdays Create Table</title></head>
<body>
<?
$db="mydata_tomorrownextweek_com";
$link = mysql_connect("sqlc11.megasqlservers.com");
$pw = "mypassword";
$user = "dbm.tomorrownextweek.com";
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db, $user, $pw, $link)
or die("Select DB Error: ".mysql_error());
//create table
mysql_query("CREATE TABLE birthdays( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), birthday VARCHAR(7))")or die("Create table Error: ".mysql_error());
mysql_close($link);

?>
</body>

</html>

NogDog
04-08-2006, 09:18 AM
Try this sequence:

<?
$db="mydata_tomorrownextweek_com";
$pw = "mypassword";
$user = "dbm.tomorrownextweek.com";
$link = mysql_connect("sqlc11.megasqlservers.com", $user, $pw);
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db, $link)
or die("Select DB Error: ".mysql_error());
//create table
mysql_query("CREATE TABLE birthdays( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), birthday VARCHAR(7))")or die("Create table Error: ".mysql_error());
mysql_close($link);

?>

kproc
04-08-2006, 09:36 AM
NogDog
thank you for the help, that worked