MySQL server version for the right syntax to use near '' at line 7

Hai friends please help me how to fix this 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 7

[php]

<?php // take in the id of a director and return his/her full name function get_director($director_id) { global $db; $query = 'SELECT people_fullname FROM people WHERE people_id = ' . $director_id; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); extract($row); return $people_fullname; } // take in the id of a lead actor and return his/her full name function get_leadactor($leadactor_id) { global $db; $query = 'SELECT people_fullname FROM people WHERE people_id = ' . $leadactor_id; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); extract($row); return $people_fullname; } // take in the id of a movie type and return the meaningful textual // description function get_movietype($type_id) { global $db; $query = 'SELECT movietype_label FROM movietype WHERE movietype_id = ' . $type_id; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); extract($row); return $movietype_label; } // function to calculate if a movie made a profit, loss or just broke even function calculate_differences($takings, $cost) { $difference = $takings - $cost; if ($difference < 0) { $color = 'red'; $difference = '$' . abs($difference) . 'million'; } elseif ($difference > 0) { $color ='green'; $difference = '$' . $difference . 'million'; } else { $color = 'blue'; $difference = 'broke even'; } return '' . $difference . ''; } //connect to MySQL $db = mysql_connect('localhost', 'root', '12345') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('param', $db) or die(mysql_error($db)); // retrieve information $query = 'SELECT movie_name, movie_year, movie_director, movie_leadactor, movie_type, movie_running_time, movie_cost, movie_takings FROM moviesite WHERE movie_id = ' . $_GET['movie_id']; $result = mysql_query($query, $db) or die(mysql_error($db)); $row = mysql_fetch_assoc($result); $movie_name = $row['movie_name']; $movie_director = get_director($row['movie_director']); $movie_leadactor = get_leadactor($row['movie_leadactor']); $movie_year = $row['movie_year']; $movie_running_time = $row['movie_running_time'] .' mins'; $movie_takings = $row['movie_takings'] . ' million'; $movie_cost = $row['movie_cost'] . ' million'; $movie_health = calculate_differences($row['movie_takings'], $row['movie_cost']); // display the information echo <<<ENDHTML Details and Reviews for: $movie_name

$movie_name

Details

Title $movie_name Release Year $movie_year
Movie Director $movie_director Cost $$movie_cost
Lead Actor $movie_leadactor Takings $$movie_takings
Running Time $movie_running_time Health $movie_health
ENDHTML; ?>[/php]

I see only one query of 7 lines. Are you sure $_GET[‘movie_id’] is filled?

Change the debugging-feedback to
[php]
$result = mysql_query($query, $db) or die( "Query : [$query]
\nError : ". mysql_error($db));
[/php]
That should at least tell you whatquery crashed it.

Good luck.
O.

Sponsor our Newsletter | Privacy Policy | Terms of Service