tags:

views:

36

answers:

2

This is very simple but I keep getting a error for some reason:

MySQL view all 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 ''LIMIT 0,6'' at line 1

$max = 'LIMIT 0,6';

$data = mysql_query("SELECT * FROM `gallery` '$max'") or die( 'MySQL view all error: ' . mysql_error());
+2  A: 

Do not quote the $max part.

Michael Krelin - hacker
+1  A: 

Your query would become; SELECT * FROM gallery 'LIMIT 0,6';

which is not a true sql query;

try this:

$data = mysql_query("SELECT * FROM gallery {$max}") or die( 'MySQL view all error: ' . mysql_error());

goddva
I was thinking it was something like that but in a similar query I use '$max' and it works. What does {} do in MySQL?
ian
Nothing in mysql - but in PHP its "protecting" the variable..
goddva
$a = 'foo';echo "$foobar"; // prints blankecho "{$foo}bar"; // prints foobar
goddva