Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 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
  #1 (permalink)  
Old April 16th, 2008, 01:49 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch3 Appendix MySQL Syntax Error

Hello. I was hoping someone could help me find out why this script isn't working. In doing the appendix excersise for chapter 3 where I need to list the movies actors and directors. I viewed the script and attempted to duplicate it however I'm getting the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Then the table is displayed with no information filled in. Any help would be much appreciated. I've been banging my head against this the past several days! Thanks in advance, the php code is as follows:

<?php
//connect to db
mysql_connect("localhost", "user", "pass") or die("Check your server connection!");
mysql_select_db("moviesite");

//function to get lead actor
function get_leadactor($lead_actor) {
    $query_leadactor = "SELECT people_fullname FROM people WHERE people.people_id = $lead_actor";
    $results = mysql_query($query_leadactor) or die(mysql_error());
    $rows = mysql_fetch_array($results);
    extract ($rows);
    $actorname=$people_fullname;
        global $actorname;
    }
//function to get lead director
function get_leaddirector($lead_director) {
global $directorname;
    $query_leaddirector = "SELECT people_fullname FROM people WHERE people.people_id = $lead_director";
    $results = mysql_query($query_leaddirector) or die(mysql_error());
    $rows=mysql_fetch_array($results);
    extract($rows);
    $directorname = $people_fullname;
    }

echo "<table border='1'>\n";
    echo "<tr>\n";
        echo "<td><strong>Movie Name</strong></td>\n";
        echo "<td><strong>Actor Name</strong></td>\n";
        echo "<td><strong>Director Name</strong></td>\n";
    echo "</tr>\n";
    $query = "SELECT * FROM movie";
    $results = mysql_query($query) or die(mysql_error());
    while ($rows = mysql_fetch_assoc($results)) {
        get_leadactor($movie_leadactor);
        get_leaddirector($movie_director);
        //build table
        echo "<tr>\n";
        echo "<td>";
            echo $movie_name;
            echo "</td>\n";
            echo "<td>";
            echo $actorname;
            echo "</td>\n";
            echo "<td>";
            echo $directorname;
            echo "</td>\n";
        echo "</tr>\n";
        }
?>
</table>



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error When Reading Appendix B riswan13 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 December 16th, 2007 10:24 PM
Trouble connecting to MySQL server (CH3) mrouse BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 October 20th, 2005 01:44 PM
Appendix F Error w/ Firefox. Palefrei BOOK: Beginning ASP 3.0 2 March 7th, 2005 02:16 PM
Ch3 Pg97 Runtime Error TaoEntropy Dreamweaver (all versions) 3 September 10th, 2003 12:21 PM





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