For a general one-to-one chat application with the requirement that it only requires Javascript and HTML on the user's computer - what makes the best sense as a design direction for a PHP solution?
Here are my ideas:
Use usleep()-based loops to hold the AJAX message-check response from the server until a message is available
Messages you send to be shown in gray instantly (client side) and then changed to black when the AJAX response confirms acceptance
touch($userid) a file when a message is sent to a user, doesn't matter who it's from - checking file_exists() is much faster than a database lookup
Store actual messages in MySQL
Use cron to run a cleanup for closed conversations and old messages
Have the client-side application fire a message check request every X-seconds, but have a response reset that counter before hanging the response waiting for a message - in this way you stop 'disconnection syndrome'