Jump to content

Recommended Posts

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;

?>

Link to comment
https://forums.phpfreaks.com/topic/186561-parse-error/
Share on other sites

<?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

Link to comment
https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985276
Share on other sites

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;
?>

Link to comment
https://forums.phpfreaks.com/topic/186561-parse-error/#findComment-985426
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.