なぜそれが であるかは述べていませんが、not working
私の推測では、//insert into events table
以下のコードでは で を使用し$newEventId
てINSERT
います。$newEventId
(mysql_num_rows(mysql_query("SELECT id FROM events WHERE EventID=$gen" )) == 0)
true
true
の値を返し、break
代わりにそれを使用してみてください$newEventId
function EventId($gen)
{
if (mysql_num_rows(mysql_query("SELECT id FROM events WHERE EventID=$gen" )) == 0) {
return $gen; // return the number that will be set as $EventId and used in the insert
break;
}
// recall function
else
{
$newEventId = rand(1000, 10000);
EventId($newEventId);
}
}
$newEventId = rand(1000, 10000);
$EventId = EventId($newEventId); // set the returned $gen to $EventId to be used in the Insert query
//insert into events table
mysql_query("INSERT INTO events ... EventID=$EventId..");