chiprivers Posted November 26, 2007 Share Posted November 26, 2007 I want to create a simple instant messaging script for my daughter to chat with her friends online within a secure enviroment that I can control. I can build the majority of this using PHP and MySQL and wondering how I can make it update with new messages as they are ready? I have googled this but all I can find is full scripts, all I need is to know is the bit to get the messages in real time! Quote Link to comment Share on other sites More sharing options...
kratsg Posted November 26, 2007 Share Posted November 26, 2007 Hmm, sounds like if I gave you a nudge, you'd instantly would be able to follow up. Check up on AJAX and PHP. AJAX uses javascript calls to PHP pages to obtain data. It's a very simple, clean method that can be used to retrieve new messages by having the PHP page run the query and return any new messages. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 26, 2007 Share Posted November 26, 2007 http://www.phpfreechat.net/ Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted November 26, 2007 Share Posted November 26, 2007 You have to have a refresh value for the chat window, since PHP is server-side. The refresh searches the database for new messages based on a timestamp. This would be fairly complicated logic and programming, not to mention mission-critical. You would need to use document.write to really do this smoothly. The other way is to pull all messages, and send n number of them to the chat window. Messages are removed from the database every n number of minutes so that only recent messages are in there. This is certainly not very efficient, but workable. I feel you may be re-creating the wheel here, as there are TONS of free IM/Chat scripts around, including some nice Flash ones. PHP developed chat screens tend to be poor environments, since you have to constantly refresh the page, which unless the user has navigation clicks turned off in their settings, produces a click every 5 or 10 seconds depending on refresh rate. You really need AJAX or Flash to get around all the caveats associated with server-side chat scripts. PhREEEk Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.