[solved]what's wrong with sql?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
TalonStriker
Forum Newbie
Posts: 8
Joined: Thu May 26, 2005 2:56 pm

[solved]what's wrong with sql?

Post 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
Last edited by TalonStriker on Mon Jul 11, 2005 11:12 am, edited 1 time in total.
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post 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";
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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
deep_fire
Forum Newbie
Posts: 7
Joined: Fri Jun 24, 2005 2:34 pm
Contact:

Try that

Post by deep_fire »

Code: Select all

$sql = &quote;SELECT * FROM  '$cat' ORDER BY 'id' DESC LIMIT $min,10&quote;;
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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 ''.
Abs
Forum Newbie
Posts: 7
Joined: Sat Jul 09, 2005 11:59 am
Location: Toronto, Canada

Post 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.
Post Reply