dongnu4254 2015-04-28 07:54 采纳率: 100%
浏览 76
已采纳

语法错误,意外':'

I have the code below, and when i load it i always get this error..

function newPlayer($wallet) {
  generate_: {
    $hash=generateHash(32);
    }
  if (mysql_num_rows(mysql_query("SELECT `id` FROM `players` WHERE `hash`='$hash' LIMIT 1"))!=0) goto generate_;
      $alias='Player_';
      $alias_i=mysql_fetch_array(mysql_query("SELECT `autoalias_increment` AS `data` FROM `system` LIMIT 1"));
      $alias_i=$alias_i['data'];
      mysql_query("UPDATE `system` SET `autoalias_increment`=`autoalias_increment`+1 LIMIT 1");
      mysql_query("INSERT INTO `players` (`hash`,`alias`,`time_last_active`,`server_seed`) VALUES ('$hash','".$alias.$alias_i."',NOW(),'".generateServerSeed()."')");
      header('Location: ./?unique='.$hash.'# Do Not Share This URL!');
      exit();
}

The error:

Parse error: syntax error, unexpected ':' in /home/a1180044/public_html/inc/functions.php on line 49

Line 49 is generate_:

  • 写回答

1条回答 默认 最新

  • duanming7961 2015-04-28 08:01
    关注

    Try to not use goto, as much as you can.

    By using goto you will be lost in your own code, because you have to search each time where your goto is pointing.

    Here you can do what you want by writing :

    if (mysql_num_rows(mysql_query("SELECT `id` FROM `players` WHERE `hash`='$hash' LIMIT 1"))!=0) {
        $hash=generateHash(32);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码