Page 1 of 1

[solved]what's wrong with sql?

Posted: Fri Jul 08, 2005 9:41 am
by TalonStriker
hi again,
can anyone tell me whether anything is wrong with this code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TSer version for the right syntax to use near 'ORDER BY id' at line 1[/quote]

Thanks !
-TSDESC LIMIT " . $min . ",10";

i'm getting 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 'ORDER BY id' at line 1[/qthat corresponds to your MySQL server version for the right syntax to use near 'ORDER BY id' at line 1
Thanks !
-TS 1[/quote]

Thanks !
-TSe215d]$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . &quote;,10&quote;;

i'm getting this error:
You have an error in your SQL syntone tell me whether anything is wrong with this code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TS. " ORDER BY id DESC LIMIT " . $min . ",10";

i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TS]

i'm getting this error:
You have an error in your SQL syntax; check the manual that corre. $cat . " ORDER BY id DESC LIMIT &quote; . $min . &quote;,10&quote;;

i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TSt . " ORDER BY id DESC LIMIT " . $min . ",10";

i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TSid' at line 1
Thanks !
-TSECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";

i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TShis code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TS" . $min . ",10";

i'm getting 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 'ORDER have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY id' at line 1
Thanks !
-TSnual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY id' at line 1
Thanks !
-TSith this code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting 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 'ORDEng 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 'ORDER BY id' at line 1
Than744b0e215d]

i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TS DESC LIMIT " . $min . ",10";

i'm getting this error:
[quote:74r anything is wrong with this code:

Code: Select all

$sql = &quote;SELECT * FROM &quote;. $cat . &quote; ORDER BY id DESC LIMIT &quote; . $min . &quote;,10&quote;;
i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TS getting 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 'ORDER BY id' at line 1
Thanks !
-TSthis code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TSith this code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TSher anything is wrong with this code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting 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 'ORDER BY id' at line 1
Thanks !
-TSuote; ORDER BY id DESC LIMIT &quote; . $min . &quote;,10&quote;;

i'm getting this error:
You have an error in your SQL syntaxll me whether anything is wrong with this code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server verss code:

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY id DESC LIMIT " . $min . ",10";
i'm getting this error:
Thanks !
-TS

Posted: Fri Jul 08, 2005 10:24 am
by djot
??

Code: Select all

$sql = "SELECT * FROM ". $cat . " ORDER BY 'id' DESC LIMIT " . $min . ",10";
]e; ORDER BY 'id' DESC LIMIT " . $min . ",10";4728e]$sql = "SELECT * FROM ". $cat . " ORDER BY 'id' DESC LIMIT " . $min . ",10";ote;,10";",10";quote;,10"; " . $min . ",10";uote;. $cat . " ORDER BY 'id' DESC LIMIT " . $min . &quote;,10&quote;;]amp;quote;. $cat . " ORDER BY 'id' DESC LIMIT " . $min . &quote;,10";1]quote;SELECT * FROM ". $cat . " ORDER BY 'id' DESC LIMIT &quote; . $min . &quote;,10&quote;;quote;. $cat . &quote; ORDER BY 'id' DESC LIMIT " . $min . ",10";amp;quote;. $cat . &quote; ORDER BY 'id' DESC LIMIT &quote; . $min . &quote;,10&quote;;p;quote;SELECT * FROM ". $cat . &quote; ORDER BY 'id' DESC LIMIT &quote; . $min . &quote;,10&quote;;amp;quote;;$sql = "SELECT * FROM ". $cat . " ORDER BY 'id' DESC LIMIT " . $min . ",10";

Posted: Fri Jul 08, 2005 10:45 am
by onion2k
At a guess I'd say that the table contained in $cat doesn't have a column called id.

EDIT: In fact, I'd venture a guess that $cat is empty.

Posted: Fri Jul 08, 2005 11:03 am
by timvw
How hard is it to echo $sql and see for yourself?


Djot: might want to read http://dev.mysql.com/doc/mysql/en/reserved-words.html

Try that

Posted: Sat Jul 09, 2005 5:04 pm
by deep_fire

Code: Select all

$sql = &quote;SELECT * FROM  '$cat' ORDER BY 'id' DESC LIMIT $min,10&quote;;

Posted: Sat Jul 09, 2005 5:25 pm
by timvw
Ok, meaby http://dev.mysql.com/doc/mysql/en/reserved-words.html was not direct enough but http://dev.mysql.com/doc/mysql/en/legal-names.html should be.

Notice that `` is not the same as ''.

Posted: Sun Jul 10, 2005 11:56 am
by Abs
Have you tried typing out the full line in the command line client and checking to see if it works? Perhaps the variables aren't being passed some values either. Echoing $sql is a good idea to see if the SQL statement is actually completed.