Jump to content

You have an error in your SQL syntax;


Pieter Lategan

Recommended Posts


HI

I got the following error can someone help.

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 'movie_year>1990 order by movie_type' at line 1

$query =  "Select movie_name, movie_type" .
"from movie" .
"where movie_year>1990 " .
"order by movie_type";
$results = mysql_query ($query)
or die (mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/240540-you-have-an-error-in-your-sql-syntax/
Share on other sites


this is my full code

<?php
//connect to MySQL
$connect = mysql_connect ("localhost", "bp5am","bp5ampass")
or die ("Hey loser, chech your server connection.");

//make sure we're using the right database
mysql_select_db("moviesite");

$query =  "Select movie_name, movie_type" .
"from movie" .
"where movie_year>1990 " .
"order by movie_type";
$results = mysql_query ($query)
or die (mysql_error());

while ($row=mysql_fetch_array($results)) {
extract($row);
echo $movie_name;
echo " - ";
echo $movie_type;
echo "<br>";
}
?>

 

this is my full code

....

 

what I was suggesting to you is echo just your query like:

$query =  "Select movie_name, movie_type" .
"from movie" .
"where movie_year>1990 " .
"order by movie_type";
// ECHO YOUR QUERY AND VALIDATE IF IT IS WHAT YOU WERE EXPECTING
echo "Query : " . $query;

//$results = mysql_query ($query)   //comment this line for now... uncomment it when you are satisfied with the echo results.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.