websocket connection with mysql-Collection of common programming errors

DISCLAIMER: This answer is directed to the OPs comments. The scripts presented are, by no means, secure. It’s preferable to use a third party FW like Ratchet

I think you’re misunderstanding how PHP works. Let me give you an example and build some explanation from that…

You have a webserver(example.com) with 2 files: a.php and b.php.

a.php