PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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 'AND Rating != 0 ORDER BY RAND() LIMIT 0,5' at line 1
If I use a fixed number it work but using the variable the error comes out...
Hi,
Echo the query you have used in your code, and just run that query on Mysql database, you use, and see what that query returns.
This way you can solve the issue.
$query = "SELECT genretypes.*, genres.*, movies.* FROM movies INNER JOIN genres ON genres.MovieID = movies.MovieID INNER JOIN genretypes ON genres.GenreTypeID = genretypes.GenreTypeID WHERE genretypes.GenreTypeID = " . $movies2['GenreID'] . " AND Rating != 0 ORDER BY RAND() LIMIT 0,5";
pjcvijay wrote:Hi,
Echo the query you have used in your code, and just run that query on Mysql database, you use, and see what that query returns.
This way you can solve the issue.
$query = "SELECT genretypes.*, genres.*, movies.* FROM movies INNER JOIN genres ON genres.MovieID = movies.MovieID INNER JOIN genretypes ON genres.GenreTypeID = genretypes.GenreTypeID WHERE genretypes.GenreTypeID = " . $movies2['GenreID'] . " AND Rating != 0 ORDER BY RAND() LIMIT 0,5";
I did that in MySQL already but replaced " . $movies2['GenreID'] . " with a fixed number and it works fine. It seems like I have some mistake in the syntax that I cannot figure out...
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
I mean, echo that variable and see what it contains!
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
I mean, echo that variable and see what it contains!
I did echo that variable. It contains the ID of the Genre that I want to base the select query on. If i write the ID manully instead of using the variable it works.