Page 1 of 1

shoutbox help

Posted: Sun Feb 01, 2004 5:56 am
by Viper78
Hello guys im new here i'm having a strange problem with my shoutbox i created i can't get the information to loop with my emoticons when i take the code away for the emoticans it works fine as soon as i add it it only shows one entry thanks for you help

Heres the code i have now.

Code: Select all

$smilie_dir = 'templates/bev/images/';

$sql = "SELECT * FROM ".$prefix."_shout";
$result = $db->query($sql);


$text = "";
while($shout = $db->fetch($result)) {
      $shout_name = $shout['name'];
      $shout_email = $shout['email'];
      $shout_www = $shout['www'];
      $shout = $shout['shout'];

      if($shout_www == "") {
          $www = "";
       } else {
          $www = "(<a href="$shout_www" target="_blank">www</a>)";
       }

       if($shout_email == "") {
          $shout_email = $shout_name;
       } else {
          $shout_email = "<a href="mailto:$shout_email">$shout_name</a>";
       }       

            
            
                   $text .= "$shout_email<font class="text">:</font>$www<br>" . addsmile($shout) . "<br><hr>";
}
echo $text;
the addsmile function is in a function.php page and got the code from one of the posts here to try to fix it but didn't work.

Thanks

Viper

Posted: Sun Feb 01, 2004 10:49 pm
by Viper78
I really need some help here guys. I'm totally stumped why it's not working.


Thanks

Viper

Posted: Mon Feb 02, 2004 4:32 pm
by DuFF
Now I'm sorry if this comes off as mean, maybe I'm venting this all on you because of the numerous posts much like this one lately, but . . .

HOW DO YOU EXPECT US TO HELP YOU? You say that the loop is not working because of the addsmile function, but you don't even show us the code to that function! 8O

Help us help you. Show us the code.

Posted: Mon Feb 02, 2004 5:02 pm
by d3ad1ysp0rk
might help to
include("function.php");
?

Posted: Mon Feb 02, 2004 8:23 pm
by Viper78
sory guys i did include the functions file and i didn't think the addsmile function would have done that because that works fine the smilies do show up just it only shows one record from the database.

heres the functions code anyway.

Code: Select all

function addsmile($shout) {
         global $db, $prefix, $smilie_dir;
         $sql = "SELECT * FROM ".$prefix."_smilies";
         $result = $db->query($sql);
         while($row = $db->fetch($result)) {
               if(!isset($smilie_code)) {
                  $smilie_code = array($row['code']);
               } else {
                  array_push($smilie_code, $row['code']);
               }
               if(!isset($smilie_url)) {
                  $smilie_url = array($row['url']);
               } else {
                  array_push($smilie_url, $row['url']);
               }
           }

           $elements = count($smilie_code);
           $tmp = count($smilie_url);
           
           if($elements !== $tmp) {
              die("Somethings wrong with the database");
           }
           for($i = 0; $i < $elements; $i++) {
               $image = "<img src="$smilie_dir/$smilie_url[$i]" title="$smilie_code[$i]" alt="$smilie_code[$i]">";
               $output = str_replace($smilie_code[$i], $image, $shout);
               $shout = $output;
           }
    return $shout;
}
thanks for your help

viper