shoutbox help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Viper78
Forum Newbie
Posts: 3
Joined: Sun Feb 01, 2004 5:56 am

shoutbox help

Post 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
Viper78
Forum Newbie
Posts: 3
Joined: Sun Feb 01, 2004 5:56 am

Post by Viper78 »

I really need some help here guys. I'm totally stumped why it's not working.


Thanks

Viper
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

might help to
include("function.php");
?
Viper78
Forum Newbie
Posts: 3
Joined: Sun Feb 01, 2004 5:56 am

Post 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
Post Reply