Wrox Programmer Forums
|
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 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
 
Old February 13th, 2012, 07:32 PM
Registered User
 
Join Date: Jan 2012
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
 
Old February 14th, 2012, 03:19 AM
Friend of Wrox
 
Join Date: Nov 2009
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
 
Old February 14th, 2012, 09:34 AM
Friend of Wrox
 
Join Date: May 2011
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. ;)
 
Old February 14th, 2012, 12:17 PM
Registered User
 
Join Date: Jan 2012
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
 
Old February 14th, 2012, 12:36 PM
Friend of Wrox
 
Join Date: May 2011
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.
 
Old February 14th, 2012, 12:38 PM
Registered User
 
Join Date: Jan 2012
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





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 03:10 AM
Problem listing database tables raphaelsenra Pro VB Databases 0 January 6th, 2005 11:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.