Thanks a lot Ace! The history is that I read the chapter in a book and felt pretty confident that I understood it all, it's still pretty basic stuff. I put together the code in the book feeling confident enough to make a few minor changes and no matter what it wouldn't work. To understand better why not I changed the code to match the book exactly and still nothing. I finally relented and went to the web site and copied and pasted the sample code into the editor....guess what! Still not working.
This is the data file code.
<?php
//Connect to mysql
$connect = mysql_connect ("localhost", "root")
or die ("Check the connection again");
//Make sure using correct database
mysql_select_db("moviedb1");
// insert data into table
$insert = "INSERT INTO movie (movie_id, movie_name, movie_type, " .
"movie_year, movie_leadactor, movie_director) " .
" VALUES (NULL, 'Lethal Weapon', 7, 1987, 1, 2), " .
"(NULL, 'Die Hard', 7, 1988, 3, 4), " .
"(NULL, 'Days of Thunder', 7, 1990, 5, 6), " .
"(NULL, 'Titanic', 2, 1997, 7,

, " .
"(NULL, 'Real Genius', 5, 1985, 9, 10), " .
"(NULL, 'Meatballs', 5, 1979, 11, 12), " .
"(NULL, 'Nightmare on Elm Street', 6, 1984, 13, 14), " .
"(NULL, 'Smokey and the Bandit', 3, 1977, 15, 16), " .
"(NULL, 'The Others', 2, 2001, 17, 18), " .
"(NULL, 'Twister', 7, 1996, 19, 20)";
$results = mysql_query($insert)
or die(mysql_error());
// insert data into movie type table
$type = "INSERT INTO movietype (movietype_id, movietype_label) " .
"VALUES (NULL, 'Sci Fi'), " .
"(NULL, 'Drama'), " .
"(NULL, 'Adventure'), " .
"(NULL, 'War'), " .
"(NULL, 'Comedy'), " .
"(NULL, 'Horror'), " .
"(NULL, 'Action'), " .
"(NULL, 'Kids')" ;
$results = mysql_query($type)
or die(mysql_error());
//Insert data into people table
$people = "INSERT INTO people (people_id, people_fullname, " .
"people_isactor, people_isdirector) " .
"VALUES (NULL, 'Mel Gibson', 1, 0), " .
"(NULL, 'Richard Donner', 0, 1), " .
"(NULL, 'Bruce Willis', 1, 0), " .
"(NULL, 'Len Wisemen', 0, 1), " .
"(NULL, 'Tom Cruise', 1, 0), " .
"(NULL, 'Tony Scott', 0, 1), " .
"(NULL, 'Leonardo Decaprio', 1, 0), " .
"(NULL, 'James Cameron', 0, 1), " .
"(NULL, 'Val Kilmer', 1, 0), " .
"(NULL, 'Martha Coolidge', 0, 1), " .
"(NULL, 'John Baushi', 1, 0), " .
"(NULL, 'Ivan Reitman', 0, 1), " .
"(NULL, 'Robert Englund', 1, 0), " .
"(NULL, 'Wes Craven', 0, 1), " .
"(NULL, 'Burt Reynolds', 1, 0), " .
"(NULL, 'Hal Needham', 0, 1), " .
"(NULL, 'Nichole Kidman', 1, 0), " .
"(NULL, 'Alejandro Amenábar', 0, 1), " .
"(NULL, 'Bill Paxton', 1, 0), " .
"(NULL, 'Jan De Bont', 0, 1)";
$results = mysql_query($people)
or die(sql_error());
echo "Data inserted successfully!";
?>
This is the code for altering the table already made to include more info.
<?php
$link = mysql_connect("localhost", "root")
or die(mysql_error());
mysql_select_db("moviedb1")
or die(mysql_error());
//alter "movie" table to include running time/cost/takings fields
$add = "ALTER TABLE movie ADD COLUMN (
movie_running_time int NULL,
movie_cost int NULL,
movie_earnings int NULL)";
$results = mysql_query($add)
or die(mysql_error());
//
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=118,
movie_cost=280,
movie_earnings=137
WHERE movie_id = 1";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=102,
$movie_cost=10,
$movie_earnings=5
WHERE movie_id = 2";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=131,
$movie_cost=60,
$movie_earningss=157
WHERE movie_id = 3";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=194,
$movie_cost=200,
$movie_earnings=1,848,
WHERE movie_id = 4";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update = "UPDATE movie SET
movie_running_time=108,
$movie_cost=1,
$movie_earnings=12
WHERE movie_id = 5";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=99,
$movie_cost=1,600,
$movie_earningss=43,046
WHERE movie_id = 6";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=91,
$movie_cost=1,800,
$movie_earnings=25,504
WHERE movie_id = 7";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=96,
$movie_cost=1,
$movie_earnings=126
WHERE movie_id = 8";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=104,
$movie_cost=17,
$movie_earnings=209
WHERE movie_id = 9";
$results = mysql_query($update)
or die(mysql_error());
//insert new data into "movie" table for each movie
$update="UPDATE movie SET
movie_running_time=113,
$movie_cost=92,
$movie_earnings=494
WHERE movie_id = 10";
$results = mysql_query($update)
or die(mysql_error());
?>
And this is the code for the page that brings it all together.
<?php
$link = mysql_connect("localhost", "root")
or die(mysql_error());
mysql_select_db("moviedb1")
or die(mysql_error());
/* Function to calculate if a movie made a profit,
loss or broke even */
function calculate_differences($movie_earnings,$movie_cost)
{
$difference = $movie_earnings - $movie_cost;
if($difference > 0)
{
$difference = substr($difference, -0);
$font_color ='blue';
$profit_or_loss = "$".$difference."m";
}
elseif($difference == 0)
{
$font_color ='green';
$profit_or_loss = "$".$difference."m";
}
else
{
$font_color ='red';
$profit_or_loss = "$".$difference."m";
}
return "<font color='$font_color'>" . $profit_or_loss . "</font>";
}
//Function to get directors name from the people table
function get_director()
{
global $movie_director;
global $director;
$query_d = "SELECT people_fullname
FROM people
WHERE people_id='$movie_director' ";
$results_d = mysql_query($query_d) or die(mysql_error());
$row_d = mysql_fetch_array($results_d);
extract ($row_d);
$director = $people_fullname;
}
//function get actors name from people table
function get_leadactor()
{
global $movie_leadactor;
global $leadactor;
$query_a = "SELECT people_fullname
FROM people
WHERE people_id='$movie_leadactor'";
$results_a = mysql_query($query_a) or die (mysql_error());
$row_a = mysql_fetch_array($results_a);
extract ($row_a);
$leadactor = $people_fullname;
}
$query = "SELECT * FROM movie WHERE movie_id='" .
$_GET['movie_id']."'";
$result = mysql_query($query, $link) or die (mysql_error());
$movie_table_headings=<<<EOD
<tr>
<th> Movie Title</th>
<th> Year of Release</th>
<th> Movie Director</th>
<th> Movie Lead Actor</th>
<th> Movie Running Time</th>
<th> Movie Health</th>
</tr>
EOD;
while ($row = mysql_fetch_array($result))
{
$movie_name = $row['movie_name'];
$movie_director = $row['movie_director'];
$movie_leadactor = $row['movie_leadactor'];
$movie_year = $row['movie_year'];
$movie_running_time = $row['movie_running_time']." mins";
$movie_earnings = $row['movie_earnings'];
$movie_cost = $row['movie_cost'];
//get director's name from people table
get_director($movie_director);
//get lead actor's name from people table
get_leadactor($movie_leadactor);
}
$movie_health = calculate_differences($movie_earnings, $movie_cost);
$page_start=<<<EOD
<HTML>
<head>
<title>Details and Reviews for: $movie_name</title>
</head>
<body>
EOD;
//global $profit_or_loss = $movie_health;
$movie_details =<<<EOD
<table width='70%' border='2' cellspacing='2' cellpadding='2' align='center'>
<tr>
<th colspan='6'><u><h2>$movie_name: Details</h2></u></th>
</tr>
$movie_table_headings
<tr>
<td width='33%' align='center'>$movie_name</td>
<td align='center'>$movie_year</td>
<td align='center'>$director</td>
<td align='center'>$leadactor</td>
<td align='center'>$movie_running_time</td>
<td align='center'>$movie_health</td>
</tr>
</table>
<br />
<br />
EOD;
$page_end =<<<EOD
</body>
</html>
EOD;
$detailed_movie_info =<<<EOD
$page_start
$movie_details
$page_end
EOD;
echo $detailed_movie_info;
mysql_close();
?>
Thanks a lot, I appreciate your encouragement!