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 March 27th, 2007, 08:38 AM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query was empty!!!!!!!!!!!!!!!!!!!!!!!!!

Ok, I spent hours looking for this error (query was empthy) and was not able to find anything wrong wiht my code! very frustrating!

I am using the "beginning PHP5, Apache, MySQL Web Development" book
the code is found on page 117

I would apprecitate if anyone can suggest ANYTHING.
My code is exactly the same as in book. Please take a look


<?php
//connect to the database
$link = mysql_connect("localhost", "root", "12345")
    or die(mysl_error());

//make sure we are using the right database
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>Movie Director</th>
    <th>Movie Lead Actor</th>
</tr>

EOD;

function get_director() {
    global $movie_director;
    global $director;

$guery_d = "SELECT people_fullname " .
     "FROM people " .
     "WHERE people_id='$movie_director'";

$results_d = mysql_query($query_d)
    or die(mysql_error());
$row_d = mysql_fetch_array($results_d);
extract($row_d);
$director = $people_fullname;
}

function get_leadactor() {
    global $movie_leadactor;
    global $leadactor;

$query_a = "SELECT people_fullname " .
     "FROM people " .
         "WHERE people_id='$movie_leadactor'";
$results_a = mysql_query($query_a)
        or die(mysql_error());
    $row_a = mysql_fetch_array($results_a);
    extract($row_a);
    $leadactor = $people_fullname;
}


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

//get director's name from poeple table
get_director();

//get actor's name from the people table
get_leadactor();


    $movie_details .=<<<EOD
    <tr>
     <td>$movie_name</td>
     <td>$director</td>
     <td>$leadactor</td>
    </tr>
EOD;
}

$movie_details .=<<<EOD
<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;
?>



There it is. Either I am VERY WRONG or the book has a typo. :(

Hope you can help out
Reply With Quote
  #2 (permalink)  
Old March 27th, 2007, 08:58 AM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also, I checked my data, everything looks ok, createmovie.php creates the table fine and moviedata.php populates the fields in the data as well.

Previous "table 2.php" (figure 4-3) on page 117 works fine as well.
As soon as I add those two functions function get_director() and function get_leadactor() I start encountering the issues....

:(

Reply With Quote
  #3 (permalink)  
Old March 27th, 2007, 10:22 AM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK NEVER MIND!

I retyped the code again, and NO ERRORS!!

It worked. Strange! I went through the code and was not able to find anything different from the previous code (code above)

so i'll get you a launch if you can figure this one :)

cheers,
gargamel

Reply With Quote
  #4 (permalink)  
Old March 27th, 2007, 10:57 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gargamel
 OK NEVER MIND!

I retyped the code again, and NO ERRORS!!

It worked. Strange! I went through the code and was not able to find anything different from the previous code (code above)

so i'll get you a launch if you can figure this one :)

cheers,
gargamel

Hey gargame1 Whats up!! haha Actually you beat me to it. I was debugging your code but you replied before I got back.. Anyways you had 2 errors in your code... I will show you them...

<?php
//connect to the database
$link = mysql_connect("localhost", "root", "12345")
    or die(mysl_error());


You had a typo it should be or die(mysql_error()); you forgot the "q"


function get_director() {
    global $movie_director;
    global $director;


This is your second error, Your variable is $guery_d instead of
$query_d...

$guery_d = "SELECT people_fullname " .
       "FROM people " .
       "WHERE people_id='$movie_director'";

$results_d = mysql_query($query_d)
    or die(mysql_error());
$row_d = mysql_fetch_array($results_d);
extract($row_d);
$director = $people_fullname;

Sorry I was a bit late... But I hope this help finds your errors. Take care and don't worry about it... Keep Coding.
-TheDudeTux

Reply With Quote
  #5 (permalink)  
Old March 27th, 2007, 11:26 AM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

wow! how could I miss that 20 times!

You are good :)!!

Thank you for your feedback and your fast reply. I am sure I will run into more serious problems down the road.

cheers,

gargamel

Reply With Quote
  #6 (permalink)  
Old March 27th, 2007, 11:32 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gargamel
 wow! how could I miss that 20 times!

You are good :)!!

Thank you for your feedback and your fast reply. I am sure I will run into more serious problems down the road.

cheers,

gargamel

No worries, haha I make mistakes too when I code from time to time, sometimes you are thinking of a lot of things. But I hate debugging so I try to pay as much attention as possible to detail, but from time to time I still mess up. Keep Programming... don't let little things hold you down.
-Peace :D haha

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
Inner empty tag jdzsolt XSLT 2 August 8th, 2008 03:49 PM
why my variable is empty? Joann Beginning VB 6 2 March 19th, 2007 04:08 PM
Is the clipboard empty? achinfish Excel VBA 1 July 15th, 2006 04:34 PM
Query was empty keiran BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 10 September 5th, 2004 10:23 AM
check if empty hosefo81 Javascript How-To 12 March 9th, 2004 08:43 AM



All times are GMT -4. The time now is 06:47 PM.


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