 |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6  | This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 26th, 2004, 02:30 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
need help with movie_details.php code
Team,
I need help with this code in chapter "4".
i have look at my code and compare it, with code in the book.
however im not able to get the correct output as displayed in
figure 4-7.
Here are my links.
http://www.theufl.com/php/wrox_php/movie_details.php
http://www.theufl.com/php/wrox_php/movie_details.php
the error that you may see of the top is not the only error, i need someone who has written this code before from book example to help me out and point out whats wrong or show me how the code should look, so that i can get my version of figure 4-7 to work.
thanks in advance for your alls help.
im trying to teach my self php but its very hard to understand.
please email me at Karl James
[email protected]
TheSaint
|
|

December 26th, 2004, 02:10 PM
|
|
Authorized User
|
|
Join Date: Dec 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
we need to see your code before anyone can offer help. please post your script.
|
|

December 26th, 2004, 02:38 PM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

December 26th, 2004, 04:28 PM
|
|
Authorized User
|
|
Join Date: Dec 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Alright, there were two things wrong with the code. One, a closing bracket was missing, and this is what was causing your parse error. Next, once I fixed that, I got a Warning from MySQL because the $review_result was defined in the wrong location. Take a look at the following section around line 130 with my corrections and notes.
$review_query = "SELECT
*
FROM
reviews
WHERE
review_movie_id ='".$_GET['movie_id']."'
ORDER BY
review_date DESC";
/*The following line was written below the following while loop. As a result,
the while loop failed because $review_result had not yet been defined.
*/
$review_result = mysql_query($review_query,$link) 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']);
}
//The above closing bracket was missing, which was the parse error you were seeing.
/*The following line is in the wrong place and should be moved above the previous while loop, as I've already indicated above:
$review_result = mysql_query($review_query,$link) or die(mysql_error());
*/
$i=0;
while($i<sizeof($review))
{
$review_details .=<<<EOD
<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>
</tr>
EOD;
###########################
One other thing I noticed is that in the beginning of your script, you had the following HTML code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>movie_details.php</title>
</head>
<body>
Now this wasn't causing any errors per se, but you're basically repeating this information twice because of the $page_start variable defined near the end of the script:
$page_start =<<<EOD
<html>
<head>
<title>Details and Reviews for: $movie_name</title>
</head>
<body>
EOD;
With all this said, what it's doing that you might not want it to is using the first <title></title> section and not the second. So you end up having movie_details.php as your page title instead of: Details and Reviews for: $movie_name. (Of course, $movie_name would be replaced with the name of the movie you're querying.)
I hope this helps and that you understand where your errors were.
Now with all due respect, what I've found to help me in learning PHP/MySQL is to figure out my own problems. Also, to help figure out others' problems as well, such as yours. I've only been reading this book and learning PHP for a little over a month now, so the little time I spent in trying to figure out your problem has taught me a lot. Thanks for the challenge.
Good luck and stick with it.
|
|
 |