The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP-General - Emotions for chat
Discuss Emotions for chat in the PHP Development forum on Dev Shed. Emotions for chat PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 1st, 2013, 05:43 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Location: Visakhapatnam
Posts: 11
Time spent in forums: 4 h 57 m 40 sec
Reputation Power: 0
|
|
|
PHP-General - Emotions for chat
Hello all,hw r u? Recently i have done chat module withphp,mysql,javascript and jquery.Chat module is working correctly.Now i want to insert emotions.I have tried and its working in weird manner.Anyone plz help...
mail me il mail u d scripts so that you can understand.
Thank you.
|

February 1st, 2013, 07:07 AM
|
|
|
Post the script here. That is what this form is for. Be sure to read ManiacDan's New User Guide first.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.
|

February 1st, 2013, 08:32 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Location: Visakhapatnam
Posts: 11
Time spent in forums: 4 h 57 m 40 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by gw1500se Post the script here. That is what this form is for. Be sure to read ManiacDan's New User Guide first. |
Hi if u dnt mind can i mail u my scripts??
|

February 1st, 2013, 08:40 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
|
Hi,
please use standard English, this "chat speak" is really hard to read -- at least for non-native speakers. Kthx.
And he just told you to post the code. Or upload it somewhere and post the link (you have to obfuscate the URL).
|

February 1st, 2013, 08:44 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Location: Visakhapatnam
Posts: 11
Time spent in forums: 4 h 57 m 40 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by Jacques1 Hi,
please use standard English, this "chat speak" is really hard to read -- at least for non-native speakers. Kthx.
And he just told you to post the code. Or upload it somewhere and post the link (you have to obfuscate the URL). |
Thank you.
|

February 1st, 2013, 11:01 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Location: Visakhapatnam
Posts: 11
Time spent in forums: 4 h 57 m 40 sec
Reputation Power: 0
|
|
|
my code
Quote: | Originally Posted by mohnish Hi if u dnt mind can i mail u my scripts?? |
Hello here is my script,please check once and correct me.
PHP Code:
<?php include("connection.php"); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
.chatbox
{
border:2px solid #990000;
height:220px;
width:450px;
overflow-y: auto;
}
.textbox
{
min-height:35px;
border:2px solid #666666;
width:450px;
margin-top:-14px;
}
</style>
<script type="text/javascript" src="js/jquery-latest.js"></script>
<script type="text/javascript" >
//$(document).ready(function()
//{
// $("#chat").emotions();
//});
function smile_display(e)
{
if (e.keyCode == 13)
{
SmileyConvert();
}
}
function SmileyConvert()
{
//alert('hi');
var text = document.getElementById('tarea').value;
//alert(text);
text = text.replace(':D', '<img src="emotions/grin.gif" border="0">');
text = text.replace('o:)', '<img src="emotions/angel.gif" border="0">');
text = text.replace(':3', '<img src="emotions/colonthree.gif" border="0">');
text = text.replace("\n", '<br>'); // How to globally replace this character ???
document.getElementById('chat').innerHTML = text;
}
//var refreshId = setInterval(function()
//{
// $('#chat').emotions();
// $('#chat').load('refreshd.php');
//}, 5000);
var user;
function user(a)
{
user=a;
document.getElementById("usr").innerHTML="you login as "+a;
}
function smiles(e)
{
//alert(event.keyCode);
if(e.keyCode == 13)
{
if((user!="user1")&&(user!="user2"))
{
alert("please login");
return false;
}
var content=document.getElementById('tarea').value;
if(content!="")
{
// document.getElementById('tarea').value="";
$.ajax({type:"post",cache:false,url:"insert.php",data:"cont="+content+"&user="+user,success:function(html)
{
//$('#chat').html(html);
$("#chat").scrollTop = $("#chat").scrollHeight;
}
});
}
}
else
{
return false;
}
}
function insertSmiley(smiley)
{
document.getElementById("tarea").value=document.getElementById("tarea").value+smiley;
tarea.focus();
}
</script>
</head>
<body>
<div id="usr">u want to login as :<input type="button" value="user1" onClick="user('user1')" />
<input type="button" value="user2" onClick="user('user2')" /></div>
<div id="chat" class="chatbox">
<table cellpadding="4px" >
<?php
$chatdata=mysql_query("select * from (select * from chatdata order by id desc limit 13) AS T1 order by id asc");
while($chatdata_exe=mysql_fetch_array($chatdata))
{
echo "<tr><td>".$chatdata_exe['user']." </td><td>:</td><td style='word-break:break-all;'>".$chatdata_exe['data']."</td></tr>";
}
?>
</table>
</div>
<table>
<tr><td>
<input type="text" class="textbox" id="tarea" onKeyPress="smiles(event);" onKeyUp="smile_display(event);" value="" />
</td><td>
<table>
<tr>
<td><img src='emotions/grin.gif' onclick="insertSmiley(':D')" /></td>
<td><img src="emotions/angel.gif" onClick="insertSmiley('o:)')" /></td>
<td><img src="emotions/colonthree.gif" onClick="insertSmiley(':3')" /></td>
<td><img src="emotions/confused.gif" onClick="insertSmiley('o.O')" /></td>
</tr>
<tr>
<td><img src="emotions/cry.gif" onClick="insertSmiley(':'(')" /></td>
<td><img src="emotions/devil.gif" onClick="insertSmiley('3:)')" /></td>
<td><img src="emotions/pacman.gif" onClick="insertSmiley(':v')" /></td>
<td><img src="emotions/gasp.gif" onClick="insertSmiley(':O')" /></td>
</tr>
<tr>
<td><img src="emotions/glasses.gif" onClick="insertSmiley('8)')" /></td>
<td><img src="emotions/grumpy.gif" onClick="insertSmiley('^_^')" /></td>
<td><img src="emotions/heart.gif" onClick="insertSmiley('<3')" /></td>
<td><img src="emotions/wink.gif" onClick="insertSmiley(';)')" /></td>
</tr>
</table>
</td></tr>
</table>
</body>
</html>
[[ Almost got that. To show PHP code, paste your code into the text editor, select it, and hit the button. --requinix
Last edited by requinix : February 2nd, 2013 at 12:59 AM.
|

February 2nd, 2013, 10:09 AM
|
|
|
|
Is it generating the output you expect? The only thing I see wrong at the moment is that you are using the deprecated MySQL extensions. You should be using PDO.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|