Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    displayin image in message when :) = image ... not working in script ??

    humm ok imy script works fine by showin the image if the right "icon" is ented via
    PHP Code:
    <?php 

    $message 
    "Hello :)";

    echo 
    emoticon($message);

    function 
    emoticon($msg){
       
    $msg str_replace(":)""<IMG src=\".http://www.website.com/members/shoutbox/images/smile.gif\">"$msg);
       return 
    $msg;
    }

    ?>
    ... but when i try and do it via my script show below .... it does not do it... have i done something wrong??
    PHP Code:
    <?
    require ("required.php");

    echo 
    "<!-- $scriptname v$version Start -->\n\n";
    echo 
    "<HTML>\n";
    echo 
    "  <HEAD>\n";
    echo 
    "    <LINK rel=\"stylesheet\" type=\"text/css\" href=\"shoutbox/tagboard.css\">\n";
    echo 
    "  </HEAD>\n";
    echo 
    "  <BODY topmargin=\"2\" leftmargin=\"2\" bottommargin=\"2\" rightmargin=\"2\">\n";
    $user2 =  $_GET['username'];
    if (
    $usemysql == 1)
      {
        
    /* Load the tagboard, the X number of most recent posts */
        
    if ($order == "0")
        
        
    $SQL "SELECT * FROM $tablname WHERE account = '$user2' ORDER BY id DESC LIMIT 3";

        
    $results mysql_db_query($database"$SQL"$connection);
        if (!
    $results)
          return (
    "ERROR: " mysql_error() . "\n$SQL\n");
        
        while (
    $row mysql_fetch_array($results))
          { 
            
    $nick     $row["nick"]; 
            
    $url      $row["url"];
            
    $message  $row["message"];
            
    $datetime $row["datetime"];

            
    /* Add Emoticons to the user's message */
            
    if ($emoticon == 1)
              
    emoticon($message);

            
    /* Some people don't have web sites, so we check to see if they put a URL in the database */
            
    if ($url=="" or $url=="http://"/* If they didn't then we just display the nick and the message */
              
    $nick "<B>$nick";
            else 
    /* If they did, then we link it!! */
              
    $nick "<B><a href=\"$url\" target=\"_blank\">$nick</a>";
            
            if (
    $timestamping == 1)
              echo 
    "    $nick ($datetime)$spacer</B> $message<BR>\n";
            else
              echo 
    "    $nick$spacer</B> $message<BR>\n";
          }
                    
          
    /* Like always, we close the connection to the database */
          
    mysql_close($connection);
      }
    else
      {
        
    $i 0;
        
    $file_lines file($flatfile);

        foreach(
    $file_lines as $line)
          {
            if (
    $i <= $howmany)
              {
                
    $delim    strpos($line"%%");
                
    $ts_delim strpos($line"@@");
                
    $ip_delim strpos($line"##");

                
    $nick substr($line0$delim);
                
    $message substr($line$delim 2$ts_delim $delim 2);
                
    $ts substr($line$ts_delim 2$ip_delim $ts_delim 2);
      
                if (
    $timestamping == 1)
                  echo 
    "    <B>$nick ($ts)$spacer</B> ";
                else 
                  echo 
    "    <B>$nick$spacer</B> ";

               
                  echo (
    emoticon($message)); 
              
                  

                echo 
    "<BR>\n";

                
    $i++;
              }
          }
      }



    function 
    emoticon($msg)
      {
        
    $msg str_replace("o:-)""<IMG src=\"http://www..com/members/shoutbox/images/angel.gif\">"$msg);
        
    $msg str_replace("o:)""<IMG src=\"http://www..com/members/shoutbox/images/angel.gif\">"$msg);
        
    $msg str_replace("O:-)""<IMG src=\"http://www..com/members/shoutbox/images/angel.gif\">"$msg);
        
    $msg str_replace("O:)""<IMG src=\"http://www..com/members/shoutbox/images/angel.gif\">"$msg);
        
    $msg str_replace(":-)""<IMG src=\"http://www..com/members/shoutbox/images//smile.gif\">"$msg);
        
    $msg str_replace(":)""<IMG src=\"http://www..com/members/shoutbox/images/smile.gif\">"$msg);

        
        return 
    $msg;
      }

    ?>

    i should add that require ("required.php"); holds $emoticon == 1
    Last edited by runnerjp; 05-16-2008 at 08:57 PM.

  • #2
    Regular Coder logictrap's Avatar
    Join Date
    Apr 2008
    Posts
    155
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Just glancing through your code shouldn't this:

    Code:
    $results = mysql_db_query($database, "$SQL", $connection);
    be

    Code:
    $results = mysql_db_query($database, $SQL, $connection);
    If you can describe in more detail what the problem is it would be helpful.

    ie Is the data being displayed but the substitution isn't working?

    Which came first - the chicken or the egg? The egg... [ticket closed]
    If a tree falls... does it make a sound? Yes.............. [ticket closed]

  • #3
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    solved


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •