Plagel Posted December 29, 2009 Share Posted December 29, 2009 Hi all. Trying to learn from a book I received..pretty sure I'm missing a character somewhere. The parse error says it's on the last line of the doc. Please help me find it! Thanks in advance. <?php $link = mysql_connect("localhost", "root", "pass") or die(mysql_error()); mysql_select_db("moviesite") or die(mysql_error()); $query = "SELECT movie_name, movie_director, movie_leadactor " . "FROM movie"; $result = mysql_query($query, $link) or die(mysql_error()); $num_movies = mysql_num_rows($result); $movie_header=<<<EOD <h2><center>Movie Review Database</center></h2> <table width="70%" border="1" cellpadding="2" cellspacing="2" align="center"> <tr> <th>Movie Title</th> <th>Year of Release</th> <th>Movie Director</th> <th>Movie Lead Actor</th> <th>Movie Type</th> </tr> EOD; 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; } while ($row = mysql_fetch_array($result)) { $movie_name = $row['movie_name']; $movie_director = $row['movie_director']; $movie_leadactor = $row['movie_leadactor']; //get director's name from people table get_director(); //get lead actor's name from people table get_leadactor(); $movie_details .=<<<EOD <tr> <td>$movie_name</td> <td>$director</td> <td>$leadactor</td> </tr> EOD; } $movie_details .=<<<EOD <tr> <td>Total :$num_movies Movies</td> </tr> EOD; $movie_footer ="</table>"; $movie =<<<MOVIE $movie_header $movie_details $movie_footer MOVIE; echo "There are $num_movies movies in our database"; echo $movie; ?> Quote Link to comment https://forums.phpfreaks.com/topic/186561-parse-error/ Share on other sites More sharing options...
Plagel Posted December 29, 2009 Author Share Posted December 29, 2009 I commented a lot of stuff..the part that seems to be generating the error is within the while part. Quote Link to comment https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985269 Share on other sites More sharing options...
oni-kun Posted December 29, 2009 Share Posted December 29, 2009 Please add your code within .. tags! But add this to after your <?php opening tag: ini_set ("display_errors", "1"); error_reporting(E_ALL); This should reveal the error rather than just halt execution, show us the error. Quote Link to comment https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985272 Share on other sites More sharing options...
Plagel Posted December 29, 2009 Author Share Posted December 29, 2009 <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $link = mysql_connect("localhost", "root", "pass") or die(mysql_error()); mysql_select_db("moviesite") or die(mysql_error()); $query = "SELECT movie_name, movie_director, movie_leadactor " . "FROM movie"; $result = mysql_query($query, $link) or die(mysql_error()); $num_movies = mysql_num_rows($result); $movie_header =<<<EOD <h2><center>Movie Review Database</center></h2> <table width="70%" border="1" cellpadding="2" cellspacing="2" align="center"> <tr> <th>Movie Title</th> <th>Year of Release</th> <th>Movie Director</th> <th>Movie Lead Actor</th> <th>Movie Type</th> </tr> EOD; 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; } while ($row = mysql_fetch_array($result)) { $movie_name = $row['movie_name']; $movie_director = $row['movie_director']; $movie_leadactor = $row['movie_leadactor']; //get director's name from people table get_director(); //get lead actor's name from people table get_leadactor(); $movie_details .=<<<EOD <tr> <td>$movie_name</td> <td>$director</td> <td>$leadactor</td> </tr> EOD; } $movie_details .=<<<EOD <tr> <td>Total :$num_movies Movies</td> </tr> EOD; $movie_footer ="</table>"; $movie =<<<MOVIE $movie_header $movie_details $movie_footer MOVIE; echo "There are $num_movies movies in our database"; echo $movie; ?> Error: Parse error: parse error in C:\Users\plagel\Desktop\local\table2.php on line 90 Quote Link to comment https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985276 Share on other sites More sharing options...
Plagel Posted December 29, 2009 Author Share Posted December 29, 2009 So..after hours of tweaking I've come nowhere..a friend has tipped me that it has to do with the quotations within my database query used when calling the string.. It's really amazing to me how far the internet has come, lolol Here is my new error message: Notice: Use of undefined constant e_all - assumed 'e_all' in C:\Users\plagel\Desktop\local\table2.php on line 3 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'people_id='1'' at line 1 and the code: <?php ini_set ("display_errors", "1"); error_reporting(e_all); $link = mysql_connect("localhost", "root", "pass") or die(mysql_error()); mysql_select_db("moviesite") or die(mysql_error()); $query = "select movie_name, movie_director, movie_leadactor " . "from movie"; $result = mysql_query($query, $link) or die(mysql_error()); $num_movies = mysql_num_rows($result); $movie_header=<<<eod <h2><center>movie review database</center></h2> <table width="70%" border="1" cellpadding="2" cellspacing="2" align="center"> <tr> <th>movie title</th> <th>year of release</th> <th>movie director</th> <th>movie lead actor</th> <th>movie type</th> </tr> eod; 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; } while ($row = mysql_fetch_array($result)) { $movie_name = $row['movie_name']; $movie_director = $row['movie_director']; $movie_leadactor = $row['movie_leadactor']; //get director's name from people table get_director(); //get lead actor's name from people table get_leadactor(); $movie_details.=<<<eod <tr> <td>$movie_name</td> <td>$director</td> <td>$leadactor</td> </tr> eod; } $movie_details.=<<<eod <tr> <td>total :$num_movies movies</td> </tr> eod; $movie_footer ="</table>"; $movie=<<<movie $movie_header $movie_details $movie_footer movie; echo "there are $num_movies movies in our database"; echo $movie; ?> Quote Link to comment https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985426 Share on other sites More sharing options...
Buddski Posted December 29, 2009 Share Posted December 29, 2009 your error_reporting is using an invalid var. error_reporting(E_ALL); // note the case and your query_a is missing a space $query_a = "select people_fullname " . "from people " . "where people_id='$movie_leadactor'"; Quote Link to comment https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985431 Share on other sites More sharing options...
Plagel Posted December 29, 2009 Author Share Posted December 29, 2009 You rock Quote Link to comment https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985439 Share on other sites More sharing options...
ignace Posted December 29, 2009 Share Posted December 29, 2009 Don't tell us we know. That's why were here Quote Link to comment https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985461 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.