Hi,there please i m new in php with intent to improve and get better.i have been running this script and it continues to give me this error message.which i suggest is from the mysql command..i will appreciate an immediate response.
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 'people.people_id = '1'' at line 1
<?php
//connect to MySQL
$connect = mysql_connect("localhost", "root", "password") or
die ("Hey loser, check your server connection.");
//make sure we’re using the right database
mysql_select_db("moviesite");
//create function to get lead actor
function get_leadactor($lead_actor) {
global $actorname;
$query2="SELECT people_fullname".
"FROM people".
"where people.people_id = '$lead_actor'";
$results=mysql_query($query2)
or die(mysql_error());
$rows=mysql_fetch_array($results);
extract($rows);
$actorname=$people_fullname;
}
//create a function to get director
function get_director($director){
global $directorname;
$query2="SELECT people_fullname".
"FROM people".
"where people.people_id = '$director'";
$results=mysql_query($query2)
or die(mysql_error());
$rows=mysql_fetch_array($results);
extract($rows);
$directorname = $people_fullname;
}
//add a header row
echo"<table border=\"1\">\n";
echo "<tr>\n";
echo "<td><strong>Movie Name</strong></td>";
echo "<td><strong>Lead Actor</strong></td>";
echo "<td><strong>Director</strong></td>";
echo "</tr>";
//get the movies
$query="SELECT * FROM movie";
$results=mysql_query($query)
or die(mysql_error());
while ($rows=mysql_fetch_assoc($results)) {
extract ($rows);
//call our functions to get specific info
get_leadactor($movie_leadactor);
get_director($movie_director);
//build the table
echo "<tr>\n";
echo "<td>\n";
echo $movie_name;
echo "</td>\n";
echo "<td>";
echo $actorname;
echo "</td>\n";
echo "<td>\n";
echo $directorname;
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
?>