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 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 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 February 13th, 2012, 06:32 PM
Registered User
Points: 31, Level: 1
Points: 31, Level: 1 Points: 31, Level: 1 Points: 31, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Location: Ontario, Canada
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default USing Tables problem.

I have checked this code from pages 111/112 and cannot find a typo BUT I get " Parse error: syntax error, unexpected $end in C:\wamp\www\movies\table2.php on line 61" The problem is there are only 60 lines in the code.
What am I missing?

Code:
<?php

//connect to MySQL
$db=mysql_connect('localhost', 'bp6am','bp6ampass') or die
('Unable to connect.Check your connection parameters');

//make sure you are using the right database.

mysql_select_db('moviesite',$db) or die (mysql_error($db));

  
//retrieve information

$query = 'SELECT
	movie_name, movie_year, movie_director, movie_leadactor, movie_type
		FROM
			movie
		ORDER BY
			movie_name ASC,
			movie_year DESC';
$result = mysql_query($query, $db) or die (mysql_error($db));

//determine the number of rows
$num_movies = mysql_num_rows($result);


$table = <<<ENDHTML
<div style="text-align: center;">
 <h2>Movie Review Database</h2>
 <table border="1" cellpadding="2" cellspacing="2"
  style="width: 70%; margin-left: auto; margin-right: auto;">
  <tr>
   <th>Movie Title</th>
   <th>Year of Release</th>
   <th>Movie Director</th>
   <th>Movie Lead Actor</th>
   <th>Movie Type</th>
  </tr>
ENDHTML;
 
 //loop through the results
 while ($row = mysql_fetch_assoc($result)) {
	 extract($row); 
	 $table .= <<<ENDHTML
	 <tr>
	 <td>$movie_name</td>
	 <td>$movie_year</td>
	 <td>$movie_director</td>
	 <td>$movie_leadactor</td>
	 <td>$movie_type</td>
	 </tr>
 ENDHTML;
 }
 $table .= <<<ENDHTML
 </table>
 <p> $num_movies Movies </p>
  </div>
  ENDHTML;
  ?>
  echo $table;
Brian
Reply With Quote
  #2 (permalink)  
Old February 14th, 2012, 02:19 AM
Friend of Wrox
Points: 742, Level: 10
Points: 742, Level: 10 Points: 742, Level: 10 Points: 742, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2009
Location: Tehran, Iran
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default extra spaces

Hi Brian

I read multiline strings in php manual and found the problem (because I don't know php!!)
you have placed spaces before ENDHTML;

[space][space]ENDHTML;

remove spaces (type less, and get less errors!!!)

see http://php.net/manual/en/language.types.string.php
__________________
happy every time, happy every where

Reza Baiat
Reply With Quote
  #3 (permalink)  
Old February 14th, 2012, 08:34 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

If you'd made it to the bottom of page 113 (the last paragraph) you would have been warned about the space issue and the 'heredoc' syntax. ;)
Reply With Quote
  #4 (permalink)  
Old February 14th, 2012, 11:17 AM
Registered User
Points: 31, Level: 1
Points: 31, Level: 1 Points: 31, Level: 1 Points: 31, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Location: Ontario, Canada
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually I read past page 113. Before submitting my problem I checked and double-checked all of the heredoc syntax - removed all spaces that I found.

I am using Geany as a writer - does this program add spaces?4 My code has, say 59 numbered lines when I save the document but when I reopen it it has 60 lines, the last one being blank.

Brian
Reply With Quote
  #5 (permalink)  
Old February 14th, 2012, 11:36 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

What OS are you using?

If using Windows there are the following:

- TextPad
- NotePad++

and when you save a file with 59 lines and then re-open it it should only have 59 lines not 60.
Reply With Quote
  #6 (permalink)  
Old February 14th, 2012, 11:38 AM
Registered User
Points: 31, Level: 1
Points: 31, Level: 1 Points: 31, Level: 1 Points: 31, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Location: Ontario, Canada
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It depends upon which computer I a using - either Windows 7 or Vista. I also have Ubuntu bit not tried LAMP yet - maybe tomorrow

Brian
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
problem with getting data from 2 tables kanoorani SQL Language 5 October 12th, 2007 05:51 PM
Linked tables problem gbrown Access 3 August 24th, 2006 01:15 PM
Select from Two Tables Problem gaurav_jain2403 SQL Server 2000 2 May 18th, 2006 07:18 AM
problem joining tables using vfpoledb in c# ACE2084 ADO.NET 2 April 1st, 2006 02:10 AM
Problem listing database tables raphaelsenra Pro VB Databases 0 January 6th, 2005 10:38 AM



All times are GMT -4. The time now is 03:39 AM.


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