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

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



All times are GMT -4. The time now is 03:06 AM.


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