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 December 16th, 2006, 09:14 PM
Authorized User
 
Join Date: Jul 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Chudz
Default Chapter 4 "Populating the Table"



Table2.php
Code:
<?php

$link = mysql_connect("localhost", "chudz_moviesite", "moviesite")
  or die("Hey loser, check your server connection.");

mysql_select_db("chudz_moviesite");

$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>Movie Director</th>
    <th>Movies Lead Actor</th>
  </tr>
</table>
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> </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 movies in our database";
    echo $movie;

?>
This is what it turned out like http://www.chudz.com/animenzb/table2.php

What have I missed or done I check out the code about 5 times now still cant see whats wrong. Why is half of the table missing :(

 
Old December 18th, 2006, 02:21 PM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Chudz. Try these "tips" (mine is working fine - but i know this can be tedious):
1.) mysql_select_db("chudz_moviesite")
  or die (mysql_error()); //you dont have an "or die"
2.) Try this also (insated of whta you had.
movie_details .="<tr>
        <td>$movie_name</td>
        <td>$director</td>
        <td>$leadactor</td>
        </tr>";
}

$movie_details .="
        <tr>
        <td>Total :$num_movies Movies</td>
        </tr>
        ";

3.) $movie ="$movie_header $movie_details $movie_footer "; // instead of
$movie =<<<MOVIE
          $movie_header
          $movie_details
          $movie_footer
MOVIE

Let me know how that works out - i will check the forum again - and hang in there.

 
Old April 16th, 2007, 06:58 PM
Registered User
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Double check to make sure there is no whitespace. Even the source code does not work for this because of whitespace here:$movie_details .=<<<EOD<whitespace> I only found this out by accident.

 
Old August 24th, 2007, 01:30 PM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HELPP!!!! PLEASE
i just got starting with this book...and now im stuck at same point as you are(hope were)....same code..but this message

Parse error: parse error, unexpected $end in C:\wamp\www\libro\table1.php on line 52

this is my code

<?php
//la conexion
$link = mysql_connect("localhost", "user", "user") or die (mysql_error());

//la base de datos
mysql_select_db ("moviesite") or die (mysql_error());

//la seleccion
$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>
</table>
EOD;
echo $movie_header;

$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;
?>

IF ANYONE CAN TAKE ME OUT OF THIS #@**&(# --- THNKS A LOT :)

 
Old August 24th, 2007, 01:31 PM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HELPP!!!! PLEASE
i just got starting with this book...and now im stuck at same point as you are(hope were)....same code..but this message

Parse error: parse error, unexpected $end in C:\wamp\www\libro\table1.php on line 52

this is my code

<?php
//la conexion
$link = mysql_connect("localhost", "user", "user") or die (mysql_error());

//la base de datos
mysql_select_db ("moviesite") or die (mysql_error());

//la seleccion
$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>
</table>
EOD;
echo $movie_header;

$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> </td>
</tr>
<tr>
<td>Total :$num_movies Movies</td>
</tr>
EOD;
?>

IF ANYONE CAN TAKE ME OUT OF THIS #@**&(# --- THNKS A LOT :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating an unbound form from a table Luis Access VBA 8 November 21st, 2008 08:37 AM
populating table from a subform based on a query bjcountry Access 1 April 11th, 2008 06:35 AM
Populating new table young20 Access VBA 1 November 15th, 2006 08:20 AM
populating cboBox with remote table data Loralee Access 8 October 31st, 2005 11:24 PM
Generate unique ID when populating a table sroman SQL Server 2000 2 August 5th, 2003 03:38 AM





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