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
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>";
}
?>

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.