Quote:
quote:Originally posted by gargamel
Sorry forgot that part :)
It is "Beginning PHP5, Apache, MYSQL Web Development"
Thanks :)
|
Hey Gargamel whats up? Hey, I found your errors.. I will place them below with ****** to show where they are.
<?php
$link = mysql_connect("localhost","root","12345")
or die(mysql_error());
mysql_select_db("moviesite")
or die (mysql_error());
function calculate_differences($takings, $cost) {
$difference = $takings - $cost;
if ($difference < 0) {
$difference = substr($difference, 1);
$font_color = 'red';
$profit_or_loss = "$" . $difference . "m";
} elseif ($difference > 0) {
$font_color ='green';
$profit_or_loss = "$" . $difference . "m";
}else {
$font_color = 'blue';
$profit_or_loss = "Broke even";
}
return "" . $profit_or_loss . "";
}
*** ?> ******** First Error *****************
You have to remove closing syntax for php... This will enable the code below to become active.... So just delete the <?
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_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 Dirctor</th>
<th>Movie Load Actor</th>
<th>Movie Running Time</th>
<th>Movie Health</th>
</tr>
********** EOD; ********** Error 2 ************
Your EOD should be all the way back to the left edge... Because of this it causes white space.
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_takings = $row['movie_takings'];
$movie_cost = $row['movie_cost'];
//get director's name from people table
get_director();
//get lead actor's name from peole table
get_leadactor();
}
$movie_health = calculate_differences($movie_takings, $movie_cost);
$page_start =<<<EOD
<html>
<head>
<title> Detais and Reviews for: $movie_name</title>
</head>
<body>
EOD;
$movie_details =<<<EOD
<table width="70%" border="0" 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();
This should be it... Next just save the work and then
http://localhost/movie_details.php You should see "Broke even" in blue text.. Don't worry their is no data yet... Simply go to
http://localhost/table3.php and click the link.. Now you will see movie_details file in action.. It will show the calculations etc.
**Note at the end of the code there is no ?> after the mysql_close(); part. I don't know if that is an error or not considering it still runs with out closing the php with <? maybe the authors kept it open for the next section not sure. But you can keep it open or close and it works.. Just a thought. Hope this helps! Take care and keep coding... -TheDudeTux