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