...

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



runnerjp
05-16-2008, 09:45 PM
humm ok imy script works fine by showin the image if the right "icon" is ented via
<?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??

<?
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, "&#37;%");
$ts_delim = strpos($line, "@@");
$ip_delim = strpos($line, "##");

$nick = substr($line, 0, $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

logictrap
05-16-2008, 10:39 PM
Just glancing through your code shouldn't this:


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

be


$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?

runnerjp
05-16-2008, 10:39 PM
solved



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum