Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 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 April 9th, 2005, 12:01 PM
Registered User
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using tables to display data (chapter 4)

Hello I get an error after this code on line 10:
Parse error: syntax error, unexpected T_SL in C:\apachefriends\xampp\htdocs\TESTPHP\table1.php on line 10: (line 10 is where $movie_header =<<<EOD begins). I also don't really understand this code: $variable =<<<EOD



the code:
<?php

$link = mysql_connect("localhost", "root", "") 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;
  $movie_details = '';
  while ($row = mysql_fetch_array($result)); {
  $movie_name = $row['movie_name'];
  $movie_director = $row['movie_director'];
  $movie_leadactor = $row['movie_leadactor'];
   $movie_details .=<<<EOD
  <tr>
  <td>$movie_name</td>
  <td>$movie_director</td>
  <td>$movie_leadactor</td>
  </tr>
  EOD;

  }
  $movie_details .=<<<EOD

 <tr>
 <td>&nbsp;</td>
 </tr>
 <tr>
 <td>Total :$num_movies Movies</td>
 </tr>

  EOD;
?>
Hope someone can help me!
Grts



 
Old April 9th, 2005, 12:26 PM
Registered User
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The heredoc syntax doesn't seem to work, what should/can I do?

 
Old April 13th, 2005, 10:18 PM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you have some spaces after you "=<<<EOD" code. I recall reading that this technique was picky about spaces after the text. If you highlight the text in your post, it looks like there is a tab at the end of line 10.
Hope this helps. I'm on chapter four as well.
Jay R

 
Old May 4th, 2005, 11:32 AM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What worked for me is to put a space on each side of the equal sign and remove the extra spaces at the end of the line.

jr
 
Old June 27th, 2006, 10:01 AM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I cannot get this to work either, p116, table2.php. I get
Parse error: parse error, unexpected $end in C:\Program Files\xampp\htdocs\wrox\table2.php on line 58
. This is probably a problem with heredocs. I have tried for days to get this to work and can't figure out what the problem is. Here's the code:
Code:
<?php
$link = mysql_connect("localhost","user","userpass")
    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>Movie Review Website</h2>
<table width="70%" border="1" cellpadding="2" cellspacing="2" align="center">
    <tr>
        <th>Movie Title</th>
        <th>Movie Director</th>
        <th>Movie Lead Actor</th>
    </tr>
EOD;

$movie_details = '';
while ($row = mysql_fetch_array($result)) {
    $movie_name = $row['movie_name'];
    $movie_director = $row['movie_director'];
    $movie_leadactor = $row['movie_leadactor'];

$movie_details .= <<<EOD
    <tr>
        <td>$movie_name</td>
        <td>$movie_director</td>
        <td>$movie_leadactor</td>
    </tr>
EOD; 
}

$movie_details .= <<<EOD
<tr>
    <td>&nbsp;</td>
</tr>
<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 in our database";
echo $movie;
?>
Help is greatly appreciated. If I can't get past this, I fear I can't go on!

 
Old August 7th, 2006, 01:42 PM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the same problem. You have too watch your spacing,
$movie =<<<MOVIE, the heredoc should beging like this. The 2nd thing don't indent too much with heredoc statements. I think the webserver are very sensitive. This should solve your problem if you haven't solved it already. I have a problem with the next chapter.


Quote:
quote:Originally posted by askohen
 I cannot get this to work either, p116, table2.php. I get
Parse error: parse error, unexpected $end in C:\Program Files\xampp\htdocs\wrox\table2.php on line 58
. This is probably a problem with heredocs. I have tried for days to get this to work and can't figure out what the problem is. Here's the code:
Code:
<?php
$link = mysql_connect("localhost","user","userpass")
    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>Movie Review Website</h2>
<table width="70%" border="1" cellpadding="2" cellspacing="2" align="center">
    <tr>
        <th>Movie Title</th>
        <th>Movie Director</th>
        <th>Movie Lead Actor</th>
    </tr>
EOD;

$movie_details = '';
while ($row = mysql_fetch_array($result)) {
    $movie_name = $row['movie_name'];
    $movie_director = $row['movie_director'];
    $movie_leadactor = $row['movie_leadactor'];

$movie_details .= <<<EOD
    <tr>
        <td>$movie_name</td>
        <td>$movie_director</td>
        <td>$movie_leadactor</td>
    </tr>
EOD; 
}

$movie_details .= <<<EOD
<tr>
    <td>&nbsp;</td>
</tr>
<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 in our database";
echo $movie;
?>
Help is greatly appreciated. If I can't get past this, I fear I can't go on!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Xslt and wml tables display arunagottimukkala XSLT 4 October 24th, 2007 03:39 AM
Multiple Tables Display in XSL bmagadi XSLT 1 February 8th, 2005 03:06 PM
Display results from multiple tables Librarian Classic ASP Databases 6 July 6th, 2004 11:28 PM





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