hey there. im new to the coding side of asp as i learnt html before hand. What im trying to do is intergreat a smilie filter in to a small chat i building for me and and some mates. The chat is using a SQL database and IIS. my current source code for it is here: -
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
-
<!--#include file="../../../../Connections/databasechat.asp" -->
-
<%
-
Dim chatmsg__MMColParam
-
chatmsg__MMColParam = "3"
-
If (Request("MM_EmptyValue") <> "") Then
-
chatmsg__MMColParam = Request("MM_EmptyValue")
-
End If
-
%>
-
<%
-
Dim chatmsg
-
Dim chatmsg_numRows
-
-
Set chatmsg = Server.CreateObject("ADODB.Recordset")
-
chatmsg.ActiveConnection = MM_databasechat_STRING
-
chatmsg.Source = "SELECT * FROM dbo.TBLmainroom WHERE TBLroom = '" + Replace(chatmsg__MMColParam, "'", "''") + "' ORDER BY ID DESC"
-
chatmsg.CursorType = 0
-
chatmsg.CursorLocation = 2
-
chatmsg.LockType = 1
-
chatmsg.Open()
-
-
chatmsg_numRows = 0
-
%>
-
<%
-
Dim Repeat1__numRows
-
Dim Repeat1__index
-
-
Repeat1__numRows = 100
-
Repeat1__index = 0
-
chatmsg_numRows = chatmsg_numRows + Repeat1__numRows
-
%>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<%Response.Expires=-1%>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-
<title>Untitled Document</title>
-
<script>
-
<!--
-
function timedRefresh(timeoutPeriod) {
-
setTimeout("location.reload(true);",timeoutPeriod);
-
}
-
// -->
-
</script>
-
<title>Untitled Document</title>
-
<style type="text/css">
-
<!--
-
body {
-
margin: 0px 0px 0px 0px;
-
.style2 {color: #0000FF}
-
.style3 {
-
font-size: 9px;
-
font-family: Arial, Helvetica, sans-serif;
-
}
-
.style6 {color: #FF00FF}
-
.style7 {font-family: Arial, Helvetica, sans-serif}
-
.style8 {
-
color: #FFFFFF;
-
font-style: italic;
-
}
-
.style10 {
-
font-family: Arial, Helvetica, sans-serif;
-
font-weight: bold;
-
font-style: italic;
-
color: #FF00FF;
-
}
-
-->
-
</style>
-
</head>
-
<body onload="javascript:timedRefresh(3000);">
-
<% If Not chatmsg.EOF Or Not chatmsg.BOF Then %>
-
<%
-
While ((Repeat1__numRows <> 0) AND (NOT chatmsg.EOF))
-
%>
-
<strong><span class="style7"><font color="#00FF00"><%=(chatmsg.Fields.Item("TBLuser").Value)%></font></span></span> </strong><span class="style7"></span>
-
<span class="style7"><font color="#9900FF"><%=(chatmsg.Fields.Item("TBLmessage").Value)%></font></span><br />
-
<%
-
Repeat1__index=Repeat1__index+1
-
Repeat1__numRows=Repeat1__numRows-1
-
chatmsg.MoveNext()
-
Wend
-
%>
-
<% End If ' end Not chatmsg.EOF Or NOT chatmsg.BOF %>
-
</body>
-
</html>
-
<%
-
chatmsg.Close()
-
Set chatmsg = Nothing
-
%>
I want to post the smiles where the <%=(chatmsg.Fields.Item("TBLmessage").Value)%> is as this displays the message. Any ideas how i go about doing this as the chat does not have any filter yet. thanks in advance.
11 2355
hey there. im new to the coding side of asp as i learnt html before hand. What im trying to do is intergreat a smilie filter in to a small chat i building for me and and some mates. The chat is using a SQL database and IIS. my current source code for it is here: -
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
-
<!--#include file="../../../../Connections/databasechat.asp" -->
-
<%
-
Dim chatmsg__MMColParam
-
chatmsg__MMColParam = "3"
-
If (Request("MM_EmptyValue") <> "") Then
-
chatmsg__MMColParam = Request("MM_EmptyValue")
-
End If
-
%>
-
<%
-
Dim chatmsg
-
Dim chatmsg_numRows
-
-
Set chatmsg = Server.CreateObject("ADODB.Recordset")
-
chatmsg.ActiveConnection = MM_databasechat_STRING
-
chatmsg.Source = "SELECT * FROM dbo.TBLmainroom WHERE TBLroom = '" + Replace(chatmsg__MMColParam, "'", "''") + "' ORDER BY ID DESC"
-
chatmsg.CursorType = 0
-
chatmsg.CursorLocation = 2
-
chatmsg.LockType = 1
-
chatmsg.Open()
-
-
chatmsg_numRows = 0
-
%>
-
<%
-
Dim Repeat1__numRows
-
Dim Repeat1__index
-
-
Repeat1__numRows = 100
-
Repeat1__index = 0
-
chatmsg_numRows = chatmsg_numRows + Repeat1__numRows
-
%>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<%Response.Expires=-1%>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-
<title>Untitled Document</title>
-
<script>
-
<!--
-
function timedRefresh(timeoutPeriod) {
-
setTimeout("location.reload(true);",timeoutPeriod);
-
}
-
// -->
-
</script>
-
<title>Untitled Document</title>
-
<style type="text/css">
-
<!--
-
body {
-
margin: 0px 0px 0px 0px;
-
.style2 {color: #0000FF}
-
.style3 {
-
font-size: 9px;
-
font-family: Arial, Helvetica, sans-serif;
-
}
-
.style6 {color: #FF00FF}
-
.style7 {font-family: Arial, Helvetica, sans-serif}
-
.style8 {
-
color: #FFFFFF;
-
font-style: italic;
-
}
-
.style10 {
-
font-family: Arial, Helvetica, sans-serif;
-
font-weight: bold;
-
font-style: italic;
-
color: #FF00FF;
-
}
-
-->
-
</style>
-
</head>
-
<body onload="javascript:timedRefresh(3000);">
-
<% If Not chatmsg.EOF Or Not chatmsg.BOF Then %>
-
<%
-
While ((Repeat1__numRows <> 0) AND (NOT chatmsg.EOF))
-
%>
-
<strong><span class="style7"><font color="#00FF00"><%=(chatmsg.Fields.Item("TBLuser").Value)%></font></span></span> </strong><span class="style7"></span>
-
<span class="style7"><font color="#9900FF"><%=(chatmsg.Fields.Item("TBLmessage").Value)%></font></span><br />
-
<%
-
Repeat1__index=Repeat1__index+1
-
Repeat1__numRows=Repeat1__numRows-1
-
chatmsg.MoveNext()
-
Wend
-
%>
-
<% End If ' end Not chatmsg.EOF Or NOT chatmsg.BOF %>
-
</body>
-
</html>
-
<%
-
chatmsg.Close()
-
Set chatmsg = Nothing
-
%>
I want to post the smiles where the <%=(chatmsg.Fields.Item("TBLmessage").Value)%> is as this displays the message. Any ideas how i go about doing this as the chat does not have any filter yet. thanks in advance.
@petvampire
Hi Vamp, and welcome to Bytes.
A couple things before I get into your question: first, we use code tags to make our posts more readable, [ code ] code goes here [ /code ] (remove the spaces to see how it works), please do the same in the future. Second, the longhand you have used for pulling up the field value is very long. The following two lines are equivalent: - <%=(chatmsg.Fields.Item("TBLmessage").Value)%>
-
<%=chatmsg("TBLmessage")%>
Hopefully if you figure that out now it will make your future coding a little easier.
So to make sure I understand you, when you response.write chatmsg("TBLmessage") you might get someting like this:
and you want the script to replace the last two characters with a smilie graphic, right?
The code to make the replacement is going to look something like this: - <%=replace(chatmsg("TBLmessage"), ":)", "<img src='smile1.gif'>")%>
Does this make sense? Now depending on the number of smileys you want to recognize you might want to make this significantly more complicated, maybe put the replace statement in a loop in a separate function call (and now my mind is going blank on how you write functions in ASP, something like this): - function smilify(chatText)
-
dim smileys(10)
-
dim smileyGraphics(10)
-
smileys(0) = ":)"
-
smileys(1) = ":S"
-
smileys(2) = ";)"
-
'...
-
smileyGraphics(0) = "<img src='smiley0.gif'>"
-
smileyGraphics(1) = "<img src='smiley1.gif'>"
-
smileyGraphics(2) = "<img src='smiley2.gif'>"
-
'...
-
-
dim fixedText
-
for x = 0 to 9
-
fixedText = replace(chatText, smileys(x), smileyGraphics(x))
-
next
-
-
response.write fixed text
-
end function
-
-
'...
-
-
smilify(chatmsg("TBLmessage"))
-
Of course you can get much fancier by keeping your smileys in a db or something, but this should work for your app. Let me know if this helps.
Jared
i could not get the script to work. i got the firsrt one to work as such. i try again and i post some more
wait both them did not work. i got this error
" microsoft VBScript runtime error '800a005e'
Invalid use of Null: 'Replace@
@petvampire
post that exact line of code. It sounds like you have a typo there.
Jared
- <%=(chatmsg.Fields.Item("TBLusername").Value)%></span>
-
<span class="style7"><font color="#9900FF">
-
<%function smilify(chatText)
-
dim smileys(10)
-
dim smileyGraphics(10)
-
smileys(0) = ":)"
-
smileys(1) = ":S"
-
smileys(2) = ";)"
-
'...
-
smileyGraphics(0) = "<img src='smiley0.gif'>"
-
smileyGraphics(1) = "<img src='smiley1.gif'>"
-
smileyGraphics(2) = "<img src='smiley2.gif'>"
-
'...
-
-
dim fixedText
-
for x = 0 to 9
-
fixedText = replace(chatText, smileys(x), smileyGraphics(x))
-
next
-
-
response.write fixed text
-
end function
-
-
'...
-
%>
-
<% smilify(chatmsg("TBLmessage")) %></font>
-
-
thats how i tried to implement it. not sure if i done it correctly as my .asp know how is still limited.
@petvampire
sorry if I wasn't clear, my ellipses (...) were supposed to be other lines you wrote if you wanted to replace more smilies with graphics. the code I wrote that you copied only replaces 3. also the code that says "for x = 0 to 9", those are supposed to be the nu8mbers for which you have smilies listed in the lines where I put ellipses. for the code you copied from my post, it only makes sense to say "for x = 0 to 2" since there are only smilies 0, 1, and 2 defined. Does this make sense? The error probably just means that it tried to find a definition for smilie(3) and you never defined it.
Let me know if this makes sense, I can probably explain it a little clearer.
Jared
Microsoft VBScript compilation error '800a03ea'
Syntax error
/apps/chat/room/thelocal/chat-display-push.asp, line 134
function smilify(chatText)
^
thats the error im now getting
Ah, I looked back over your code, and I actually gave you the code as a subroutine even though I said to use "function ... end function". Change the word "function" both at the beginning and end of that block of code to "sub" and see if it works.
Jared
still no joy. this is the error now Microsoft VBScript compilation error '800a03ea'
Syntax error
/apps/chat/room/thelocal/chat-display-push.asp, line 144
sub smilify(chatText)
^
hmm. It works for me. here is the complete code I tested, and I got no error. - <%
-
sub smilify(chatText)
-
dim smileys(10)
-
dim smileyGraphics(10)
-
smileys(0) = ":)"
-
smileys(1) = ":S"
-
smileys(2) = ";)"
-
'...
-
smileyGraphics(0) = "<img src='smiley0.gif'>"
-
smileyGraphics(1) = "<img src='smiley1.gif'>"
-
smileyGraphics(2) = "<img src='smiley2.gif'>"
-
'...
-
-
dim fixedText
-
fixedText = chatText
-
for x = 0 to 9
-
fixedText = replace(fixedText, smileys(x), smileyGraphics(x))
-
response.write "<!-- -->" & vbNewLine
-
next
-
-
response.write fixedText & "<br>" & vbnewline
-
end sub
-
-
%>
-
<html>
-
<head><title></title>
-
</head>
-
<body>
-
<%
-
dim chatMsg
-
chatmsg="hi there LOL :)"
-
-
smilify(chatMsg)
-
-
'response.write chatMsg & "<br>" & vbNewLine
-
response.write "hello world"%>
-
</body>
-
</html>
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Robin Cull |
last post by:
Imagine I have a dict looking something like this:
myDict = {"key 1": , "key
2": , "key 3": ,
"key 4": }
That is, a set of keys which have a variable length list of associated
values after...
|
by: Robert Neville |
last post by:
I would like to add filter functionality to my database whether
through the Main form or the subform. This question may be
rudimentary, yet I have not less experience with filtering data
outside...
|
by: CSDunn |
last post by:
Hello,
I have a problem with field filtering between an Access 2000 Project form
(the application is called CELDT), and the report that shows the results of
the filter. Both the form and the...
|
by: Richard |
last post by:
Hi,
I have a form based on a table. When I filter the form I want to run a
report based on the same table with the same filter as the form. No problem
until I want to filter a combo box where...
|
by: dick |
last post by:
I am just trying to print/report the results of a "filter by
selection" which is done by right-clicking a form, filling in values,
and "applying the filter."
I have searched the newsgroups, and...
|
by: Salad |
last post by:
I have a log file with a list of records. The log file can be
unfiltered or filtered.
I have a command button to call a data entry form from the log. At
first I was only going to present the...
|
by: Mike Sweetman |
last post by:
I have a form Form1 which when the Advanced Filter/Sort is used
creates a form(maybe) with a title 'Form1Filter1 : Filter'. When I
apply the filter to Form1 it is applied, but the value of...
|
by: marcus.kwok |
last post by:
I am having a weird problem and I have can't figure out why it is
happening. I create an OpenFileDialog and set a filename filter. When
the dialog first opens, the filter works correctly, and...
|
by: Briansmi1116 |
last post by:
I created two buttons, that filter my form, They filter in different Fields, and if one is filtered, and the other is not there is a certain amount of record, if they are both pushed, then there is...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |