//-------------- Chat server BY Kilvish ------------ <?php // Establish MySQL database connection $servername = "localhost" ; $username = "root" ; $password = "" ; $dbname = "chatdb" ; $conn = new mysqli ( $servername , $username , $password , $dbname ); if ( $conn -> connect_error ) { die ( "Connection failed: " . $conn -> connect_error ); } // Retrieve chat messages from the database function getChatMessages () { global $conn ; $sql = " SELECT * FROM chat_messages ORDER BY created_at ASC " ; $result = $conn -> query ( $sql ); $messages = array (); if ( $result -> num_rows > 0 ) { while ( $row = $result -> fetch_assoc ()) { $messages [] = $row ; } } return $messages ; } // Insert a new chat message into the data...