How would this be done?

Can someone help me here please.

iam writing a multi player bingo game i have chose to write it using as3 flash php mysql,

i have a big problem and can’t seem to figure it out, the game is built on 3 frames using as3 1st frame is where they shuffle and select there tickets, when the timer reaches 0 it goes to the next frame frame 2 where random numbers are pulled from mysql using urlloader and php , this is where the problem starts,

i have tried getting the numbers from one table called randnumber in the database but what happens is if i play the game using 2 users both users get different numbers not the same numbers.

so i made 2 more tables one table called thegame and another table called tempnumber so what happens now is, the first user that enters the game gets the number from the table called randnumber post the number into the table called tempnumber then all the other users should get the numbers from the tempnumber table, but what happens is the first user starts to call the numbers but no numbers called for all other uses,
i suppose what im trying to do is have one bingo caller call the numbers

but can’t seem to do it.

this is the php code i have done

 $query = sprintf("SELECT * FROM thegame  ",    
				 mysql_real_escape_string($start));
 $result = mysql_query($query);
 
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\
";
    $message .= 'Whole query: ' . $query;
    die($message);
}

while ($row = mysql_fetch_assoc($result)) {
 $start= $row['start'];
	
}
// Perform Query
$result = mysql_query($query);
$returnVars = array();
$returnVars['start'] = "$start";

$returnString = http_build_query($returnVars);


 if ($start == 0) {
$num = $_POST['num'];
$num = 0;
$res = mysql_query('SELECT num FROM randnumber WHERE called = 1 ORDER BY RAND() LIMIT 1');
if(1 === mysql_num_rows($res)){  
$row = mysql_fetch_assoc($res); 
mysql_query(sprintf('UPDATE randnumber SET called = 0 WHERE num = %d LIMIT 1',

$row['num']));  
$num = $row['num'];
} 
mysql_query("UPDATE thegame SET start= 1 ");
   if (@mysql_query($sql1)) {



		 }

					
$sql = mysql_query("INSERT INTO tempnum (num,called) 
     VALUES('$num',1)")  
     or die (mysql_error());
          exit(); 
 }

	 if ($start == 1) {
	$res = mysql_query('SELECT num FROM tempnum WHERE called = 1 LIMIT 1');
if(1 === mysql_num_rows($res)){  
$row = mysql_fetch_assoc($res); 
mysql_query(sprintf('update  tempnum set  called = 0',
$row['num']));  
$num = $row['num'];
if($start == 1){
$start = $_POST['start'];
    $sql = mysql_query("UPDATE thegame SET start= 0 "); 		
} 
 printf('num=%d', $num);

}
         exit(); 
	
	 }

i hope some can understand what im trying to do
thanks

Hi i have the users login and keep track of sessions if users don’t login they can’t enter the game.
can’t understand if i use the back end and update the database manually it works. but if i write a update query and put it in my php script it doesn’t work, but it is updating the database, but the game wont work properly.
i am baffled

HI
could someone please have a look at my php code please

i will explain what i want the code to do

 	$query = sprintf("SELECT * FROM thegame  ",    
				 mysql_real_escape_string($start));
 $result = mysql_query($query);
 
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\
";
    $message .= 'Whole query: ' . $query;
    die($message);
}

while ($row = mysql_fetch_assoc($result)) {
 $start= $row['start'];
	
}
// Perform Query
$result = mysql_query($query);
$returnVars = array();
$returnVars['start'] = "$start";

$returnString = http_build_query($returnVars);


 if ($start == 0) {
$num = $_POST['num'];
$num = 0;
$res = mysql_query('SELECT num FROM randnumber WHERE called = 1 ORDER BY RAND() LIMIT 1');
if(1 === mysql_num_rows($res)){  
$row = mysql_fetch_assoc($res); 
mysql_query(sprintf('UPDATE randnumber SET called = 0 WHERE num = %d LIMIT 1',

$row['num']));  
$num = $row['num'];
} 
mysql_query("UPDATE thegame SET start= 1 ");
   if (@mysql_query($sql1)) {



		 }

					
$sql = mysql_query("INSERT INTO tempnum (num,called) 
     VALUES('$num',1)")  
     or die (mysql_error());
          exit(); 
 }

	if ($start == 1) {
	$res = mysql_query('SELECT num FROM tempnum WHERE called = 1 LIMIT 1');
if(1 === mysql_num_rows($res)){  
$row = mysql_fetch_assoc($res); 
mysql_query(sprintf('UPDATE tempnum SET called = 0',
$row['num']));  
$num = $row['num'];


} 			
 printf('num=%d', $num);


         exit(); 
	
	 }

the problem is with this bit of code

 mysql_query("UPDATE thegame SET start= 1 ");
   if (@mysql_query($sql1)) {

if i put this bit of code at the bottom of the main code above my code doesent work like it should.

 mysql_query("UPDATE thegame SET start= 0 ");
   if (@mysql_query($sql1)) {

but if i go into my database and open thegame table and manually change the 1 to 0 it works great but as soon as i put my update query in my code it doesn’t work, it is updating the table ok, so it is updating, its just my game wont work unless i keep updating the database manually.

could someone help me here been on this a long time. i will post more info if required.

thankyou,

My advice is to have the users log in with a nickname and use sessions to keep track of users (set up a random number id even). From there you can attach a user to their bingo values. Now if you and I were in a game you can tell how many bingo matches I have and how many you have.

Hope I’m on the right track.