Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 11th, 2003, 03:58 PM
Authorized User
 
Join Date: Jul 2003
Location: Houston, Texas, USA.
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nvillare
Default Chat Room Trouble

I am trying to create a chat room consisting of 2 pages, the index and the chat room. The index page allows you to login by giving a chat name to use during the session, the chatroom allows you to see the message and insert new messages. However it is not working and I can't figure out what the problem is. Please advice.

index.asp

<%@ language="VBScript"%>
<%
'code tuns when the form is submitted
'if Go is present then form has beed submitted
if not isempty(Request.Form("Go")) then
 'connection is established
 set MyConn = server.CreateObject("adodb.connection")
 MyConn.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="& Server.MapPath("\nvillare\db\nidia.mdb"))
 'session variable chatname is set to name supplied by user
 Session("ChatName") = Request.Form("ChatName")
 'text of thread is set to an empty string
 Session("Thread") = ""

 set RSLastEntry = MyConn.Execute("select Max(ChatID) as MaxID from ChatRoom")
 'checks to see the last entry in the dbs
 'if none then it is set to 0
 if isnumeric(RSLastEntry("MaxID")) then
   Session("LastEntry") = RSLastEntry("MaxID")
 else
   Session("LastEntry") = 0
 end if
 'user is directed to the chat page
 Response.Redirect "./chat.html"
 end if
%>

chat.html consists of body.asp and footer.asp

body.asp
<% Language=VBScript%>
<%
'connection to the dbs to retrieve any new threads
set MyConn = server.CreateObject("adodb.connection")
MyConn.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="& Server.MapPath("\nvillare\db\nidia.mdb"))
'retrieve any new entries entered after the last entry was received
set RSMessage = MyConn.Execute("select ChatID, Message from ChatRoom where " _
 & "ChatID > " & Session("LastEntry"))
'code loops through each record
do until RSMessage.EOF
 'append new message to the current thread
 Session("Thread") = Session("Thread") & RSMessage("Message") &
  chr(13)
  'next time page refreshes it will not grab the old message
  Session("LastEntry") = RSMessage("ChatID")
  RSMessage.MoveNext
Loop
%>

footer.asp
<%@ Language=VBScript %>
<%
'checks to see if the button has been pressed
if not isempty("Request.Form("addMessage")) then
 'if it has been pressed then it will connect to the dbs
 set MyConn = server.CreateObject("adodb.connection")
 MyConn.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="& Server.MapPath("\nvillare\db\nidia.mdb"))
 'the message is added to the dbs
 MyConn.Execute "insert into ChatRoom (WhenEntered, Message) values
  (" _
  & "'" & Now & "', " _
  & "'" & Session("ChatName") & ": " & Request.Form("txtMessage") & "')"
  'page is refreshed by redirecting to the chat page
  Response.Redirect "./chat.html"
 end if
%>

Thanks for your help!!

Nidia
__________________
Thanks!

N




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chat Room aliusmankhan ASP.NET 2.0 Professional 2 August 23rd, 2008 07:51 AM
GUI chat room mralam Java GUI 4 October 30th, 2007 04:46 AM
Online Chat Room pro-logic .NET Web Services 0 October 20th, 2003 05:26 AM
Chat Application uxi ASP.NET 1.0 and 1.1 Basics 0 October 1st, 2003 06:27 AM
Chat Room Creation HELP! nvillare Classic ASP Basics 2 August 28th, 2003 06:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.