Jump to content

Archived

This topic is now archived and is closed to further replies.

HoTDaWg

Pretty Noobish error....

Recommended Posts

hey,

I have the following script:
[code]
<?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>");





?>
[/code]

Now i get the following error:
[code]
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
[/code]

Any help would greatly be appreciated,

HoTDaWg

Share this post


Link to post
Share on other sites
Dont have the comma ( , ) after DESC?


soo..

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

Share this post


Link to post
Share on other sites
Remove the comma between the words "DESC" snd "LIMIT"

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.