Oops, the error message points to the following line,
$conn = mysql_real_connect("localhost", "", "");
$select = mysql_select_db("chapter7", $conn);
I have added this at the beginning, <?php
$link = mysql_connect('localhost', '', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully Dude';
mysql_close($link);
//?>
and get the message, Connected successfully Dude, but then get the error following that.
Here is all the script<html>
<head>
<title>SaveRoom.php</title>
</head>
<body>
<?php
$link = mysql_connect('localhost', '', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully Dude';
mysql_close($link);
//?>
//<?PHP
//Once a room has been edited by editSegment, this program
//updates the database accordingly.
//check to see what values came in
foreach ($_REQUEST as $key=>$value){
//print "$key: $value<br>";
} // end foreach
//connect to database
$conn = mysql_real_connect("localhost", "", "");
$select = mysql_select_db("chapter7", $conn);
$sql = <<<HERE
UPDATE adventure
SET
name = $name,
description = $description,
north = $north,
east = $east,
south = $south,
west = $west
WHERE
id = $id
HERE;
//print $conn;
//print $select;
//print $sql;
$result = mysql_real_query($sql);
print $result;
if ($result){
print "<h3>$name room updated successfully</h3>n";
print "<a href = "listSegments.php">view the rooms</a>n";
} else {
print "<h3>There was a problem with the database</h3>n";
} // end if
?>
</body>
</html>
I am running this on my machine at home.
Thanks
Mike