title: PHP websocket server and mysql connection
body: <p>I have a php websocket server based on <a href="http://code.google.com/p/php-websocket-server/" rel="nofollow">this one</a>. This websocket server runs on a different apache than the public webserver but on the same physical server so I need a database connection to retrieve userdata. The userdata is fetched by the current session id which is also updated in the database when a user loggs in. Now, if I run my websocket server it works perfect but after a decent time (can't say a timespan) the result stays empty. I checked the dataset.</p>
  
  <p>The querystring is up to date and the correct session id is in the database which should return the desired row but the result stays empty. If I kill the process and run this websocket server, it will work for the time being but after a while the result is empty again.</p>
  
  <p>This is my websocketserver.php simplified:</p>
  
  <pre><code>set_time_limit(0);
  require 'class.PHPWebSocket.php';
  
  $db1 = mysql_connect( 'localhost', 'dev', 'xxxxxxxx' );
  mysql_select_db('cb_dev',$db1);
  
  function wsOnMessage($clientID, $message, $messageLength, $binary) {
      global $Server;
  
      $sessionid = "/*just imagine a session id here*/";
      $result = mysql_query("SELECT username, id FROM users WHERE sessionid = '$sessionid'");
      $row = mysql_fetch_row($result);
  }
  
  function wsOnOpen($clientID) {
      //
  }
  
  function wsOnClose($clientID, $status) {
      //
  }
  
  $Server = new PHPWebSocket();
  $Server-&gt;bind('message', 'wsOnMessage');
  $Server-&gt;bind('open', 'wsOnOpen');
  $Server-&gt;bind('close', 'wsOnClose');
  
  $Server-&gt;wsStartServer('0.0.0.0', 9010);
  </code></pre>
  
  <p>Note: The used session id is served correctly so this is not the problem.</p>