Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 26th, 2004, 02:30 AM
Registered User
 
Join Date: Dec 2004
Location: tampa, fl, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kjames1973 Send a message via AIM to kjames1973 Send a message via MSN to kjames1973 Send a message via Yahoo to kjames1973
Default 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




karl.james@verizon.net
TheSaint
Reply With Quote
  #2 (permalink)  
Old December 26th, 2004, 02:10 PM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

we need to see your code before anyone can offer help. please post your script.

Reply With Quote
  #3 (permalink)  
Old December 26th, 2004, 02:38 PM
Registered User
 
Join Date: Dec 2004
Location: tampa, fl, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kjames1973 Send a message via AIM to kjames1973 Send a message via MSN to kjames1973 Send a message via Yahoo to kjames1973
Default

The code is listed here;

http://www.theufl.com/php/wrox_php/movie_details.phps

i forgot to name it .phps; sorry!

karl.james@verizon.net
TheSaint
Reply With Quote
  #4 (permalink)  
Old December 26th, 2004, 04:28 PM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
movie_details.php issues gargamel BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 12 October 24th, 2010 07:02 AM
PHP to parse C code ratanatyrupp Pro PHP 1 January 25th, 2008 06:38 AM
Chapter 4 P124 - movie_details Pheeal Beginning PHP 0 January 27th, 2006 10:16 AM
php - should i code my site with this? bennn Beginning PHP 6 November 25th, 2004 09:31 AM
PHP code error Yee Dreamweaver (all versions) 1 October 21st, 2004 04:14 PM



All times are GMT -4. The time now is 12:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.