View Single Post
  #1 (permalink)  
Old April 16th, 2008, 01:49 PM
amin7b5 amin7b5 is offline
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:

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

//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);
        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());
    $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)) {
        //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";