MySQL
  Home arrow MySQL arrow Page 2 - A MySQL Driven Chat Script
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

A MySQL Driven Chat Script
By: Tim Pabst
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 213
    2001-12-25

    Table of Contents:
  • A MySQL Driven Chat Script
  • Creating the database
  • The chat script explained
  • The chat script explained (contd.)
  • The chat script explained (contd.)
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    A MySQL Driven Chat Script - Creating the database


    (Page 2 of 6 )

    Every time a visitor logs in to our chat room, they choose a nickname/alias. When they post a new message, it’s stored in a database along with any other messages in that chat session. At any one time, only the twenty most recent messages will be displayed in the chat window. We will create a database named “chat”. The “chat” database will contain just one table, named “chatScript”.

    Start by typing “MySQL” at the command prompt to load the MySQL console app. Next, enter the commands shown below, each one separated by a new line:

    create database chat;

    create table chatScript

    (

    pk_Id int unsigned auto_increment,

    theText varchar(100) not null,

    theNick varchar(20) not null,

    primary key(pk_Id),

    unique id(pk_Id)

    );


    This will create our chat database and table. The “pk_Id” field is simply an auto-incrementing number, and will assign a new numerical id to each of our chat messages when they are added to the database. The “theText” field will contain the actual chat message posted by the user. The “theNick” field will contain the nickname of the user posting the message. Lastly, the “pk_Id” field is set as the primary key of the chatScript table. It is also declared as a unique id, which stops us from manually entering a duplicate value for the “pk_Id” field.

    To make sure our new chat database was created successfully and is working, let’s try connecting to it through the MySQL console app and inserting a record into the chatScript table, like this:

    connect chat;

    insert into chatScript values(0, 'This is a test message', 'TestUser');


    That’s all there is to creating the database for our chat application. Now let’s look at creating the PHP script which will allow our visitors to login and post messages.

    More MySQL Articles
    More By Tim Pabst


       · not work
       · The code does not work at all in its present form.A number of bugs are there. For...
       · this is i have coppied and tested . but it is not working right. pls check and reply...
       · The code is absolutely rubbish. It does not work. A dirty joke by the writter
       · We're sorry the code doesn't work for you. I think you will find that our more...
     

    MYSQL ARTICLES

    - MySQL and BLOBs
    - Two Lessons in ASP and MySQL
    - Lord Of The Strings Part 2
    - Lord Of The Strings Part 1
    - Importing Data into MySQL with Navicat
    - Building a Sustainable Web Site
    - Creating An Online Photo Album with PHP and ...
    - Creating An Online Photo Album with PHP and ...
    - PhpED 3.2 – More Features Than You Can Poke ...
    - Creating An Online Photo Album with PHP and ...
    - Creating An Online Photo Album with PHP and ...
    - Security and Sessions in PHP
    - Setup Your Personal Reminder System Using PHP
    - Create a IP-Country Database Using PERL and ...
    - Developing a Dynamic Document Search in PHP ...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT