help with smilies

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
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

help with smilies

Post by Smackie »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


My friend asked me to add some smilies in his comment box and well for some reason everything coming out in text and not in smilies i am not getting any errors but can someone help me please

Code: Select all

<?php
include 'db.php';

$comment = mysql_query("SELECT * FROM comment WHERE filter = 'pic1' ORDER BY date DESC");
while ($row = mysql_fetch_array($comment)) {
	$username = $row['username'];
	$message = $row['message'];
	echo "<font color='FF9AFF'><center><b>$username</b>: $message</font></center><br>";

}

if ( isset ( $_POST['message'] ) )
{
	
	$name = addslashes($_POST['username']);
	$message =  $_POST['message'];
	
	if ( ( isset($username) ) && ( isset($message) ) )
	{
  
// getting smilie list
$smilies = mysql_query("SELECT * FROM smilies") or die(mysql_error());
while($get = mysql_fetch_array ($smilies))
{

$alt = $get['Alt'];
$smilie = $get['URL'];

$message = str_replace( $get['Symbol'] , '<img src="smilies/'.$smilie.'" border="0" width="15" height="15" alt="'.$alt.'">' , $message);
$themessage = addslashes($message);

// replacing all smilies
}
}
}
	?>
	<center><form action="insert.php" METHOD="post"> 
<br><br><br><font color="FF9AFF">Name:</font><br>
<input type="input" name="username" size="30" value="" class="input-box"><br>
<font color="FF9AFF">Message:</font><br> 
<input type="input" name="message" size="30" value="" class="input-box"><br>
<input name="filter" type="hidden" value="pic1">
<p><input type="submit" name="submit" value="Submit"> 
</form>
</center>

Thank you
Smackie


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You've been around long enough to know to use

Code: Select all

tags smackie...
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

Sorry :? i didnt double check on what i was doing i was in a hurry i had some stuff i had to get done asap :?
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

I'd set error reporting to E_ALL and look for undefined variable notices.
Post Reply