SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Non-Member sketchynetwk's Avatar
    Join Date
    Dec 2004
    Location
    UK, England
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Syntax Error, Making A Forum...HELP

    Me and a friend are making our own forum software but i've come to a problem with pulling from the database, this is the error i keep getting:

    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 'desc FROM forums WHERE active = '1' && catid = '1' ORDER BY for

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\web\snbb\functions.php on line 262

    now this is the coding around that area:
    PHP Code:
        php:$sql "SELECT fid, title, desc FROM forums WHERE active = '1' && catid = '$c_id' ORDER BY forum_order ASC";
            
    $forums mysql_query($sql);
            echo 
    mysql_error();
            while(
    $f=mysql_fetch_array($forums))
        { 

    and this is the database structure that it is pulling from:
    Code:
    CREATE TABLE `forums` (
    `fid` int(10) unsigned NOT NULL auto_increment,
    `title` varchar(50) NOT NULL default '',
    `desc` varchar(255) NOT NULL default '',
    `active` int(11) NOT NULL default '1',
    `catid` int(11) NOT NULL default '0',
    `forum_order` decimal(10,0) NOT NULL default '1',
    `levels` varchar(50) NOT NULL default '',
    PRIMARY KEY (`fid`)
    ) TYPE=MyISAM ;
    I have no idea why it isn't working, the query seems fine to me, the database structure seems fine and and so does the other coding.

    Can anyone else help me?
    Thanks,

    Rick

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    DESC is a reserved word

    use DESCR and you're in business
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Non-Member sketchynetwk's Avatar
    Join Date
    Dec 2004
    Location
    UK, England
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, It Worked

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    texas
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and can you use '&&' in your SQL? i always use 'AND' ...
    free online calendar: http://inversiondesigns.com
    includes multiple calendars/users/groups, task manager,
    email and sms reminders, permissions (sharing), etc.

  5. #5
    Non-Member sketchynetwk's Avatar
    Join Date
    Dec 2004
    Location
    UK, England
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    makes no difference (that i know of)

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by sketchynetwk
    makes no difference (that i know of)
    the difference is, if you ever move off mysql, that's just one more syntax correction straw on the conversion project camel's back

    AND is standard sql and all databases support it
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    Non-Member sketchynetwk's Avatar
    Join Date
    Dec 2004
    Location
    UK, England
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ditto lol


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •