Ruth Posted March 21, 2008 Share Posted March 21, 2008 I keep getting this error: syntax error, unexpected T_ECHO I know I'm missing something stupid but can't find it could you guys help. Here is my code. <?php require_once ('dbconnection.php'); //function to calc profit or loss function calculate_differences ($takings, $cost) { $difference = $takings - $cost; if ($difference < 0) { //substr will not display negative just num $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 "<font color=\"$font_color\">" .$profit_or_loss."</font>"; } //function to get director from db function get_director() { global $movie_director; global $director; $query_d = "SELECT people_fullname FROM people WHERE people_id = '$movie_director'"; $result_d = mysql_query ($query_d) or die (mysql_error()); $row_d = mysql_fetch_array($result_d); extract ($row_d); $director = $people_fullname; } //function to get actor from db function get_leadactor() { global $movie_leadactor; global $leadactor; $query_a = "SELECT people_fullname FROM people WHERE people_id = '$movie_leadactor'"; $result_a = mysql_query($query_a) or die (mysql_error()); $row = mysql_fetch_array($result_a); $leadactor = $row['people_fullname']; } //function to display image function generate_ratings($review_rating) { $movie_rating = ''; for ($i = 0; $i < $review_rating; $i++) { $movie_rating .= "<img src = \"thumbsup.gif\"> "; } return $movie_rating; } $movie_query = "SELECT * FROM movie WHERE movie_id = '".$_GET['movie_id']."' "; $movie_result = mysql_query($movie_query) or die(mysql_error()); $movie_table_headings = <<<stop <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> stop; $review_table_headings = <<<stop <tr> <th>Date of Review</th> <th>Review Title</th> <th>Reviewer Name</th> <th>Movie Review Comments</th> <th>Rating</th> </tr> stop; while ($row = mysql_fetch_array($movie_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']; //call functions get_director(); get_leadactor(); } $review_query = "SELECT * FROM reviews WHERE review_movie_id ='".$_GET['movie_id']."' ORDER BY review_date DESC"; $review_result = mysql_query($review_query) or die(mysql_error()); while ($review_row = mysql_fetch_array($review_result)) { $review_flag = 1; $review_title[] = $review_row['review_name']; $reviewer_name[] = ucwords($review_row['review_reviewer_name']); $review[] = $review_row['review_comment']; $review_date[] = $review_row['review_date']; $review_rating[] = generate_ratings($review_row['review_rating']); } $movie_health = calculate_differences($movie_takings, $movie_cost); $page_start = <<<stop <html> <head> <title>Details and Reviews for: $movie_name</title> </head> <body> stop; $movie_details = <<<stop <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> stop; if ($review_flag) { $movie_details .=/*<<<stop*/ echo "<table width = '95%' border = '0' cellspacing = '2' cellpadding = '20' align='center'>"; $review_table_headings; $review_details; echo "</table>"; //stop; } $i = 0; $review_details = ''; while ($i < sizeof($review)) { $review_details .= <<<stop <tr> <td width = "15%" valign = "top" align = "center">$review_date[$i]</td> <td width = "15%" valign = "top">$review_title[$i]</td> <td width = "10%" valign = "top">$reviewer_name[$i]</td> <td width = "50%" valign = "top">$review[$i]</td> <td width = "10%" valign = "top" align = "center">$review_rating[$i]</td> stop; $i++; } $page_end = <<<stop </body> </html> stop; $detailed_movie_info = <<<stop $page_start $movie_details $page_end stop; echo $detailed_movie_info; mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/97265-syntax-error-help/ Share on other sites More sharing options...
kenrbnsn Posted March 21, 2008 Share Posted March 21, 2008 Please give us a hint -- what is the full error message -- which line does it indicate. Also, please surround your code with tags. Ken Link to comment https://forums.phpfreaks.com/topic/97265-syntax-error-help/#findComment-497695 Share on other sites More sharing options...
BlueSkyIS Posted March 21, 2008 Share Posted March 21, 2008 this will not compile. your error message should have included a line number which makes finding errors much easier. if ($review_flag) { $movie_details .=/*<<<stop*/ echo "<table width = '95%' border = '0' cellspacing = '2' cellpadding = '20' align='center'>"; $review_table_headings; $review_details; echo "</table>"; //stop; } Link to comment https://forums.phpfreaks.com/topic/97265-syntax-error-help/#findComment-497697 Share on other sites More sharing options...
Jeremysr Posted March 21, 2008 Share Posted March 21, 2008 It's here: if ($review_flag) { $movie_details .=/*<<<stop*/ echo "<table width = '95%' border = '0' cellspacing = '2' cellpadding = '20' align='center'>"; $review_table_headings; $review_details; echo "</table>"; //stop; } It looks like you want to put this: if ($review_flag) { $movie_details .= "<table width = '95%' border = '0' cellspacing = '2' cellpadding = '20' align='center'>". $review_table_headings. $review_details. "</table>"; //stop; } Link to comment https://forums.phpfreaks.com/topic/97265-syntax-error-help/#findComment-497700 Share on other sites More sharing options...
Ruth Posted March 21, 2008 Author Share Posted March 21, 2008 Parse error: syntax error, unexpected T_ECHO in C:\projects\pratice\WWW\ch04\movie_details.php on line 162 The error is in the echo <table> line if ($review_flag) { $movie_details .=/*<<<stop*/ echo "<table width = '95%' border = '0' cellspacing = '2' cellpadding = '20' align='center'>"; $review_table_headings; $review_details; echo "</table>"; //stop; } Link to comment https://forums.phpfreaks.com/topic/97265-syntax-error-help/#findComment-497702 Share on other sites More sharing options...
Ruth Posted March 21, 2008 Author Share Posted March 21, 2008 if ($review_flag) { $movie_details .=/*<<<stop*/ echo "<table width = '95%' border = '0' cellspacing = '2' cellpadding = '20' align='center'>"; $review_table_headings; $review_details; echo "</table>"; //stop; } I deleted the /*<<<stop and the //stop; and it still didn't work Link to comment https://forums.phpfreaks.com/topic/97265-syntax-error-help/#findComment-497705 Share on other sites More sharing options...
Jeremysr Posted March 21, 2008 Share Posted March 21, 2008 Do you want to echo it or concatenate it with $movie_details? If you want to concatenate it, use the code I posted above. If you want to echo it, try this: if ($review_flag) { echo "<table width = '95%' border = '0' cellspacing = '2' cellpadding = '20' align='center'>", $review_table_headings, $review_details, "</table>"; } Link to comment https://forums.phpfreaks.com/topic/97265-syntax-error-help/#findComment-497709 Share on other sites More sharing options...
Ruth Posted March 21, 2008 Author Share Posted March 21, 2008 Ok the error went away but my description wont show up. If its not one bloody thing its another. Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/97265-syntax-error-help/#findComment-497711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.