goto在php中没有提供语法错误,第10行意外':'

Khu*_*jaz 0 php mysql goto

以下是我正在使用的代码

Again:
  $rand = mt_rand(100000,999999);
  $sql = "select * from replogins where access_code = $rand";
      $res = mysql_query($sql); 
  if(mysql_num_rows($res))
goto Again;
Run Code Online (Sandbox Code Playgroud)

请帮忙

dee*_*see 5

你可以用while循环轻松替换goto,解决你的问题并同时摆脱goto.;)

do {
    $rand = mt_rand(100000,999999);
    $sql = "select * from replogins where access_code = $rand";
    $res = mysql_query($sql); 
} while(mysql_num_rows($res));
Run Code Online (Sandbox Code Playgroud)