By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

Smilies in asp database

P: 11
Hi there, i have a website i am working on and i want to be able to let users use smiles but i cant get them to work. Any ideas here is my main body
Expand|Select|Wrap|Line Numbers
  1. <%function smilify(chatText) 
  2.    dim smileys(10) 
  3.    dim smileyGraphics(10) 
  4.    smileys(0) = ":)" 
  5.    smileys(1) = ":S" 
  6.    smileys(2) = ";)" 
  7.    smileyGraphics(0) = "<img src='smiley0.gif'>" 
  8.    smileyGraphics(1) = "<img src='smiley1.gif'>" 
  9.    smileyGraphics(2) = "<img src='smiley2.gif'>" 
  10.    dim fixedText 
  11.    for x = 0 to 9 
  12.       fixedText = replace(chatText, smileys(x), smileyGraphics(x)) 
  13.    next 
  14.    response.write fixed text 
  15. end function 
  16. %>
  17. <% smilify(RSsb("RSmsg")) %>
  18.  
Aug 10 '11 #1

✓ answered by Rabbit

Sorry, I should have caught this way earlier. Change all references of fixedText to chatText. You are replacing your fixedText value every time without keeping the results.

Share this Question
Share on Google+
16 Replies


Rabbit
Expert Mod 10K+
P: 12,369
That looks like it should work fine. What are you seeing instead of the smilies?
Aug 10 '11 #2

P: 11
I am getting this error

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/test.asp, line 38

response.write fixed text
---------------------^



I know there are data in the database, and :) in posts in random places as people post the messages
Aug 10 '11 #3

Rabbit
Expert Mod 10K+
P: 12,369
You have a space in your variable [fixed text]
Aug 10 '11 #4

P: 11
I have tried removing that but now it displays the page with no icons or any red cross. it shows it with out any emote :(
Aug 10 '11 #5

Frinavale
Expert Mod 5K+
P: 9,731
Are the smiley#.gif files in the same directory as the page?

-Frinny
Aug 10 '11 #6

P: 11
they are but they are not displaying. i am not even getting the icon for a missing icon
Aug 10 '11 #7

Frinavale
Expert Mod 5K+
P: 9,731
Right click on your page in the browser.
Find the HTML generated for the smiley's <img> tag and post it here so we can take a look.
Aug 10 '11 #8

Rabbit
Expert Mod 10K+
P: 12,369
Did you try a fully qualified path?
Aug 10 '11 #9

P: 11
http://cullinan.myep.co.uk/shoutbox/test.asp is the web page i am working on and images are on http://www.cullinan.myep.co.uk/shoutbox/smiley2.gif (i am using random images to test it as i got to wait for my designer to sort out the smilies graphics in the morning
Aug 10 '11 #10

Rabbit
Expert Mod 10K+
P: 12,369
Have you tried using the full path?
Aug 10 '11 #11

P: 11
Sadly its not working at all. i did try that, I even checked the images are there. The shout box it’s for is automatically updating but even on the static feed it calls from the images are not there.
Aug 10 '11 #12

Rabbit
Expert Mod 10K+
P: 12,369
Can you repost your current code? You can leave out the connection info if you want.
Aug 10 '11 #13

P: 11
Here is my Current Code as it stands.
Expand|Select|Wrap|Line Numbers
  1.  <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <!--#include file="../Connections/******.asp" -->
  3. <%
  4. Dim RSsb
  5. Dim RSsb_numRows
  6.  
  7. Set RSsb = Server.CreateObject("ADODB.Recordset")
  8. RSsb.ActiveConnection = MM_production_STRING
  9. RSsb.Source = "SELECT * FROM dbo.RSshoutbox ORDER BY ID DESC"
  10. RSsb.CursorType = 0
  11. RSsb.CursorLocation = 2
  12. RSsb.LockType = 1
  13. RSsb.Open()
  14.  
  15. RSsb_numRows = 0
  16. %>
  17. <%
  18. Dim Repeat1__numRows
  19. Dim Repeat1__index
  20.  
  21. Repeat1__numRows = -1
  22. Repeat1__index = 0
  23. RSsb_numRows = RSsb_numRows + Repeat1__numRows
  24. %>
  25. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  26. <html xmlns="http://www.w3.org/1999/xhtml">
  27. <head>
  28. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  29. <title>Untitled Document</title>
  30. <style type="text/css">
  31. <!--
  32. body,td,th {
  33.     font-size: 12px;
  34. }
  35. body {
  36.     margin-left: 0px;
  37.     margin-top: 0px;
  38.     margin-right: 0px;
  39.     margin-bottom: 0px;
  40. }
  41. .style2 {
  42.     font-size: 16px;
  43.     font-family: Arial, Helvetica, sans-serif;
  44. }
  45. .style3 {
  46.     color: #FF00FF;
  47.     font-weight: bold;
  48. }
  49. -->
  50. </style></head>
  51.  
  52. <body>
  53. <div align="left" class="style2"><span class="style3"><%=(RSsb.Fields.Item("RSname").Value)%>:</span>
  54.   <%function smilify(chatText) 
  55.    dim smileys(10) 
  56.    dim smileyGraphics(10) 
  57.    smileys(0) = ":)" 
  58.    smileys(1) = ":S" 
  59.    smileys(2) = ";)"
  60.    smileys(3) = ":p" 
  61.    smileys(4) = ":("
  62.    smileys(5) = ";("
  63.    smileys(6) = ":o"
  64.    smileys(7) = ":D"
  65.    smileys(8) = ":$"
  66.    smileyGraphics(0) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley0.png'>" 
  67.    smileyGraphics(1) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley1.png>" 
  68.    smileyGraphics(2) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley2.png'>"
  69.    smileyGraphics(3) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley3.png'>"
  70.    smileyGraphics(4) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley4.png'>"
  71.    smileyGraphics(5) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley5.png'>"
  72.    smileyGraphics(6) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley6.png'>"
  73.    smileyGraphics(7) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley7.png'>"
  74.    smileyGraphics(8) = "<img src='http://www.cullinan.myep.co.uk/shoutbox/smiley8.png'>"
  75.    dim fixedText
  76.    for x = 0 to 9 
  77.       fixedText = replace(chatText, smileys(x), smileyGraphics(x)) 
  78.    next 
  79.    response.write fixedtext 
  80. end function 
  81. %>
  82.   <% 
  83. While ((Repeat1__numRows <> 0) AND (NOT RSsb.EOF)) 
  84. %>
  85.     <% smilify(RSsb("RSmsg")) %>
  86.     <br />
  87.     <% 
  88.   Repeat1__index=Repeat1__index+1
  89.   Repeat1__numRows=Repeat1__numRows-1
  90.   RSsb.MoveNext()
  91. Wend
  92. %>
  93. </div>
  94. </body>
  95. </html>
  96. <%
  97. RSsb.Close()
  98. Set RSsb = Nothing
  99. %>
  100.  
Aug 10 '11 #14

Rabbit
Expert Mod 10K+
P: 12,369
Sorry, I should have caught this way earlier. Change all references of fixedText to chatText. You are replacing your fixedText value every time without keeping the results.
Aug 10 '11 #15

P: 11
Wow did the trick. only other thing i am having trouble with that code is how to make the images smaller like using the width="16" height="16" style tags
Aug 10 '11 #16

Rabbit
Expert Mod 10K+
P: 12,369
Since that is a new question, please post it in a new thread.
Aug 11 '11 #17

Post your reply

Sign in to post your reply or Sign up for a free account.