Jump to content

smartDa

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

smartDa's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=386765:date=Jun 22 2006, 02:29 AM:name=v3x)--][div class=\'quotetop\']QUOTE(v3x @ Jun 22 2006, 02:29 AM) [snapback]386765[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM forum_topics WHERE forumid = '" . $fid . "' AND pinned = '0' ORDER BY id ASC"),0) or die(red_message("An error has occurred") . "<br \>" . red_message(mysql_error() ? mysql_error() : "No MySQL error to show") . "<br \>ID: 1");[/code] You can ignore everything after "or". It doesn't give me an error message from mysql_error(). Also there's 1 row in the table "forum_topics" where [b]pinned[/b] is "1". If I set [b]pinned[/b] to "0" it works fine. So what I want to know is why doesn't it work when I have one topic in the forum where [b]pinned[/b] is "1"? I know I have [b]WHERE pinned = '0'[/b] in the query itself, but I just don't understand it. If someone could provide a solution I'd greatly appreciate it! Thanks in advance. ---brandon Edit: I've found a solution for it by checking if there's any rows first, then if so, do mysql_result: [code]            $query = "SELECT * FROM forum_topics WHERE forumid = '" . $fid . "' AND pinned = '0'";             $result = mysql_query($query) or die(red_message(mysql_error()));             if(mysql_num_rows($result) > 0)             {                 // BUILD LINKS                 $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM forum_topics WHERE forumid = '" . $fid . "' AND pinned = '0' ORDER BY id ASC"),0) or die(red_message("An error has occurred") . "<br \>" . red_message(mysql_error() ? mysql_error() : "No MySQL error to show") . "<br \>ID: 1");                 $total_pages = ceil($total_results / $max_results); [/code] Is there another way though? [/quote] First why do you have Arithmetic parameters in "" quote? As an integer, the 0 value is mathematically operable. Putting it in quote simply vabous it and will not carry out any incre/decrement on it.
×
×
  • Create New...

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.