Jump to content


Photo

Pretty Noobish error....


  • Please log in to reply
2 replies to this topic

#1 HoTDaWg

HoTDaWg
  • Members
  • PipPipPip
  • Advanced Member
  • 275 posts
  • LocationToronto

Posted 16 July 2006 - 03:45 AM

hey,

I have the following script:
<?php

$conn = mysql_connect("localhost","*****","******");
mysql_select_db("*********");

    $limit          = 3;               
    $query_count    = "SELECT count(*) FROM news";    
    $result_count   = mysql_query($query_count);    
    $totalrows      = mysql_num_rows($result_count); 

    if(empty($page)){
        $page = 1;
    }
        

    $limitvalue = $page * $limit - ($limit); 
    $query  = "SELECT * FROM news ORDER BY date DESC, LIMIT $limitvalue, $limit ";        
    $result = mysql_query($query) or die("Error: " . mysql_error()); 

    if(mysql_num_rows($result) == 0){
        echo("Nothing to Display!");
    }

    $bgcolor = "#E0E0E0"; // light gray

    echo("<table width=\"100%\" border=\"0\" height=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
    
    while($row = mysql_fetch_array($result)){
        if ($bgcolor == "#E0E0E0"){
            $bgcolor = "#CCCCCC";
        }else{
            $bgcolor = "#E0E0E0";
        }

    echo("<tr bgcolor=".$bgcolor."><td width=\"10\">");
    echo($row["id"]);
    echo("</td><td width=\"60%\"><li>");
    echo($row["content"]);
    echo("</td><td width=\"30%\">");
    echo($row["today"]);
    echo("</td></tr>");
    }

    echo("</table>");



 

?>

Now i get the following error:
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, 3' at line 1

Any help would greatly be appreciated,

HoTDaWg

Handy links:
Google
PHP Manual


#2 leeming

leeming
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 16 July 2006 - 03:47 AM

Dont have the comma ( , ) after DESC?


soo..

$query  = "SELECT * FROM news ORDER BY date DESC LIMIT $limitvalue, $limit ";   

Im not perfect ;) lol

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 16 July 2006 - 03:49 AM

Remove the comma between the words "DESC" snd "LIMIT"

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users