WorldDrknss Posted July 3, 2007 Share Posted July 3, 2007 I have created a server using sockets similar to: http://us.php.net/manual/en/ref.sockets.php. I run the script from the command line using php -q /path to php file. The problem is using mysql queries within the do events. On my script I replaced echo "$buf\n" with my mysql information and a query string. example - parts edited: do { $send_socket = socket_accept($socket); //REMOVED //REMOVED do { $buff = socket_read($send_socket, 2048); if(!$buff = trim($buff)){ continue; } if($buff == 'shutdown'){ socket_close($send_socket); break 2; } list($username, $chat ) = explode("|", $buff); //EXAMPLE $conn=@mysql_connect("SOME SERVER", "SOME USERNAME", "SOME PASSWORD") or die("Could Not Connect to MySQL"); $database=@mysql_select_db("SOME DATABASE", $conn) or die("Could Not Connect to Database"); $add_chat = mysql_query("INSERT INTO chat (username, chat) VALUES('$username', $chat')"); break; } while (true); socket_close($send_socket); } while (true); but unfortunately the queries will not work. Quote Link to comment Share on other sites More sharing options...
WorldDrknss Posted July 3, 2007 Author Share Posted July 3, 2007 I got it figured out. 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.