Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 Search this Thread Display Modes
  #1 (permalink)  
Old December 16th, 2006, 09:14 PM
Authorized User
 
Join Date: Jul 2004
Location: Connah\'s Quay, , United Kingdom.
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 :(

Reply With Quote
  #2 (permalink)  
Old December 18th, 2006, 02:21 PM
Authorized User
 
Join Date: Jul 2006
Location: Happaugh, NY, .
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.

Reply With Quote
  #3 (permalink)  
Old April 16th, 2007, 06:58 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old August 24th, 2007, 01:30 PM
Registered User
 
Join Date: Aug 2007
Location: , , .
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 :)

Reply With Quote
  #5 (permalink)  
Old August 24th, 2007, 01:31 PM
Registered User
 
Join Date: Aug 2007
Location: , , .
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 :)

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
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



All times are GMT -4. The time now is 01:02 AM.


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