Page 3 of 3

Posted: Sun Nov 27, 2005 3:09 pm
by gaogier
anyone know what i have to do?

Posted: Sun Nov 27, 2005 4:00 pm
by josh
gaogier wrote:anyone know what i have to do?
change that

Code: Select all

$topic_result = mysql_query ($topic_query);
to output the error using mysql_error()

Posted: Sun Nov 27, 2005 5:39 pm
by gaogier
sorry, but i dont understand what your saying

Posted: Sun Nov 27, 2005 10:29 pm
by shiznatix
here. look at like 51. notice that its realllllly strange looking. you cant just start a line and do '.$news; that makes no sence. then right after that you call }else{ well, else what? there is not initial if to then do the else. just does not make sence. i think this might be what you want.

Code: Select all

<?php
# News Db script - index.php

function displayNews($all = 0) {
global $sitestyle;
    require_once ('../mysql_connect1.php');//connect to db
    if ($all == 0) {   
            $topic_query = "SELECT * FROM `ipb_topics` WHERE `forum_id`= '1' ORDER BY `topic_time` DESC LIMIT 7"; // do topic query
    }else{
            $topic_query = "SELECT * FROM `ipb_topics` WHERE `forum_id`= '63' ORDER BY `topic_time` DESC"; // do topic query
    }
        $topic_result = mysql_query ($topic_query);
            while ($topic_row = mysql_fetch_assoc($topic_result)) {
                $tt = $topic_row['topic_time'];
                $topic = $topic_row['topic_id'];
                  $poster = $topic_row['topic_poster'];
                $first = $topic_row['topic_first_post_id'];
                $title = $topic_row['topic_title'];
                $topic_replies = $topic_row['topic_replies'];
                $post_query = "SELECT * FROM `ipb_posts` WHERE  `topic_id` = '$topic' AND `poster_id` = '$poster' AND `post_id` = '$first'"; // do post subject query
                $post_result = mysql_query($post_query);
                while ($post_row = mysql_fetch_assoc($post_result)){
                    $post_id = $post_row['post_id'];
                }
                $use_query = "SELECT `username`, `user_avatar`, `user_email`, `user_rank` FROM `ipb_users` WHERE `user_id` = '$poster'"; // do user query
                $use_result = mysql_query($use_query);
                while ($use_row = mysql_fetch_assoc($use_result)){
                     $user = $use_row['username'];
                     $user_avatar = $use_row['user_avatar'];
                     $user_email = $use_row['user_email'];
                     $rank = $use_row['user_rank'];                    
                }
                $news_query = "SELECT `post_text` FROM `ipb_posts_text` WHERE `post_id`='$post_id'";
                $news_result = mysql_query($news_query);
                while ($news_row = mysql_fetch_assoc($news_result)){
                    $news = $news_row['post_text'];
                }
                $rank_result = mysql_query("SELECT `rank_title` FROM `ibp_ranks` WHERE `rank_id`='$rank'");
                while($rank_row = mysql_fetch_assoc($rank_result)){
                    $ranks = $rank_row['rank_title'];
                }
                $date = date("D M jS, Y g:i a", $tt);
                if ($topic_replies == 0){
                $reply = '<a href="http://www.nozhosting.com/forums/posting.php?mode=reply&t='.$topic.'">Nobody has commented on this piece of news yet. Be the first!</a>';
                $post_new ="";
                }else{
                $reply =  'comments(<a href="http://www.nozhosting.com/forums/viewtopic.php?t='.$topic.'">'.$topic_replies.'</a>) |';
                $post_new = '<a href="http://www.nozhosting.com/forums/posting.php?mode=reply&t='.$topic.'">Post a comment</a>';
                }
                // Replace newlines //
                $news1 = $news;//this does not make any sence either but OK!
                $news2 = str_replace("\n", "\n<br />\n", $news1);
        ?>
    
         <table border="0" cellpadding="0" cellspacing="0" width="100%" class="news">
        <tr>
          <td></td>
          <td><div align="center"><p class="small2"><a href="http://www.nozhosting.com/forums/viewtopic.php?t=<?php echo $topic; ?>" class="news"><?php echo $title; ?></a> posted by <a href="http://www.nozhosting.com/forums/profile.php?mode=viewprofile&u=<?php echo $poster; ?>"><?php echo $user; ?></a> on <?php echo $date;?></p></font></div></td>
          <td height="25" width="30"></td>
           </tr>
      </table>

             <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td width="16"></td>
         <td align="center" border="0" cellpadding="0" cellspacing="0">
          
               <img src="<?php echo $user_avatar; ?>" ><br /><center><font class="small2"><b><?php echo $ranks; ?></b></font></center></td>
            <td width="429"> <p><font class="small2">
      <p><?php echo $news2; ?></p><br>
      <br /><font class="small2"><?php echo $reply. ' '. $post_new;?>
</td>
          </tr>
          </table>
      
  </div><br />
    <?php
    }
    
    /* if we aren't displaying all news,
     * then give a link to do so */
    if ($all == 0) {
        echo "<center><a href=\"{$_SERVER['PHP_SELF']}" .
             "?action=all\">View all news</a></center>\n";
    }else{
            echo "<center><a href=\"".$_SERVER['PHP_SELF']."?action=all\">View all news</a></center>\n";
    }

}
echo "<CENTER>\n";
switch($_GET['action']) {
    case 'all':
        displayNews(1);
        break;
    default:
        displayNews();
}
echo "</CENTER>\n";
?>
although most of this just does not make sence. not sure what you are going for here.

Posted: Mon Nov 28, 2005 7:10 am
by gaogier
i am tring to make a news post, that is shown when someone posts news in the news and anounsments page (the news should show how many replys have been made, the user avater and the user who posted it)

Posted: Tue Nov 29, 2005 8:33 am
by gaogier
i believe i have got rid of that error, but i now have this error, which i dont understand, as line 99 is ?>



Parse error: parse error, unexpected $ in /home/gaming/public_html/index.php on line 99

Code: Select all

echo "<center><a href=\"".$_SERVER['PHP_SELF']."?action=all\">View all news</a></center>\n";
    }

}
echo "<CENTER>\n";
switch($_GET['action']) {
    case 'all':
        displayNews(1);
        break;
    default:
        displayNews();
}
echo "</CENTER>\n";
?>

Posted: Tue Nov 29, 2005 8:36 am
by Jenk
That usually means you are missing a close brace ( } )

tally up the number of open braces vs close braces and adjust as necessary (you might have an extra { and not short on }'s)

Posted: Tue Nov 29, 2005 8:42 am
by gaogier
i have 14 of both

Posted: Tue Nov 29, 2005 8:47 am
by php3ch0
Your error is in this bit

Code: Select all

mode=reply&t='.$topic.'">Post a comment</a>'; 
                } 
                '.$news; 
                }else{

Posted: Tue Nov 29, 2005 8:50 am
by php3ch0
look at the colour formatting

Posted: Tue Nov 29, 2005 8:52 am
by gaogier
where did you get that? i dont see it

Posted: Tue Nov 29, 2005 11:14 am
by gaogier
back to this error

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/gaming/public_html/index.php on line 13

i worked it out

fixed