Jump to content

Chat app without database


lordzardeck

Recommended Posts

you would need to use ajax (js) or flash to make it "real time."  You would need to store the chat text in a central place so that when someone writes something, it can be displayed for everybody.  If you don't want to store the info in a database, your only other option is with a flatfile. 

 

With a file, consisting of the chat? That's basically what a database is tbh. Why not use a db?

perhaps his hosting does not allow him to have a db?

Link to comment
Share on other sites

Well, actually, my host does give mysql db's but they forbid using for chat. Quite frankly i wouldn't want the load on the server anyways. So there is no way to do that type of app without a db? Even without flat file? The main reason I ask is i'm wanting to make an online game in php and ajax, that works similar to a chat system. I figured learning how a chat system would be made would help me make this game. If it can't be done without a db, I guess I'll just have to use sql lite.

Link to comment
Share on other sites

Use a flatfile, and limit the amount of lines stored in the file

its the easiest way. you can put the file off the web folder, so no one can access it

or use .htaccess to deny access to that folder

 

If not done this way, u need a full time service in order to keep all the data in memory.

 

php just runs when requested to run, so u need to store the info u get from chat somewhere, when its not being requested.

 

Link to comment
Share on other sites

use a txt file

write input to the text file

draw input back out of txt file

print to frame

auto refresh the frame every .2 second

disable refresh sound with java script.

real time chat with .txt base filing

chron job to wipe the file clean every ten minutes or so.

 

most of this you can do with PHP but some things would have to be handled via java

like refreshing just the frame and not the whole page. Also java would be needed to go to the end of that doc instead of starting at the beginning. I've actually seen this done 0nce or twice. I'll look for the source and post a link if i find it in a timely manor.

Link to comment
Share on other sites

An iframe would munch on your bandwidth. You'd be better using ajax.

 

And I wouldn't have a cron job delete old stuff either - it could wipe out a long convo while someone was still talking.

 

I'd go with the .txt file if I were you though, and protect it with .htaccess.

 

And maybe check to see if the file has been modified in the last day or something. If it hasn't; chances are the conversation is over, so you can delete it.

 

That's how I'd do it anyway.

Link to comment
Share on other sites

Yeah, i would rather it be in a mysql db but I have 1&1, so my hosting provider basically sucks. But hey, it's cheap, affordable, and it provides the best options for $5. But sql lite should be okay. Anyone have anyideas where I can read about making a chat app with php and ajax?

Link to comment
Share on other sites

I don't know, if it's shared hosting and there are multiple sites using the same mysql server, they probably don't want people overloading it with chat applications. It probably would be faster, but if everyone on that server did it, it'd be slow as...something really slow, and overloading all the time.

Link to comment
Share on other sites

files must be read and parsed when making standard http requests anyways.  There's not a whole lot different going on, as far as server load, than a server just reading a file directly on the server.  It really boils down to how much coding you have to do to keep track of what's in the file.  The overall point of a database is that the data is structured for easier handling so you don't have to write a bunch of code to keep track and parse a file as a whole.  But...with a basic chat app...there really isn't all that much to it.  You could have it simply append the latest entry to the end no problem.  It might actually be more efficient to just use a flatfile for a basic chat app.  "Basic" being the keyword, though. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.