Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中发送给GCM的注册ID上循环_Php_Android_Mysql_Google Cloud Messaging - Fatal编程技术网

在PHP中发送给GCM的注册ID上循环

在PHP中发送给GCM的注册ID上循环,php,android,mysql,google-cloud-messaging,Php,Android,Mysql,Google Cloud Messaging,我在这里遇到了一个问题,就是在PHP中循环使用MYSQL数据库中的注册ID。 这是我实现它的方式,但我确信它出了问题 $apiKey = array(); $i = 0; if($_POST['course1'] == '1') { while($row = mysql_fetch_array(mysql_query("SELECT Registration_id FROM students WHERE course1 ='1' ")))

我在这里遇到了一个问题,就是在PHP中循环使用MYSQL数据库中的注册ID。 这是我实现它的方式,但我确信它出了问题

$apiKey = array();
    $i = 0;
    if($_POST['course1'] == '1')
    {
        while($row = mysql_fetch_array(mysql_query("SELECT Registration_id FROM students WHERE course1 ='1' ")))
        {

            $apiKey[$i] = $row['Registration_id'];
            $i++;

        }

    }
但在这里它给了我一个Android LogCat中的错误,如下所示:

11-27 16:56:25.336: E/JSON(972): Array<br />n<b>Fatal error</b>:  Maximum execution
 time of 30 seconds exceeded in
 <b>/home/Php/send.php</b> on line
 <b>34</b><br />n
11-27 16:56:25.346: E/JSON Parser(972): Error parsing data org.json.JSONException:
Value Array<br of type java.lang.String cannot be converted to JSONObject
11-27 16:56:25.336:E/JSON(972):数组
n致命错误:最大执行次数 在中超过30秒的时间 /home/Php/send.Php联机 34
n 11-27 16:56:25.346:E/JSON解析器(972):解析数据org.JSON.JSONException时出错:
值数组您的PHP脚本花费了太多时间来完成。这意味着您的循环可能永远运行

在每次循环迭代中查询数据库时,结果是$row始终是查询的第一行

另一方面,您不应该再使用
mysql\uquot
函数(它们已被弃用,请参阅PHP文档)

尝试以下方法:

$query_result = mysql_query("SELECT Registration_id FROM students WHERE course1 ='1' ");
while ($row = mysql_fetch_array( $query_result ) ) {
  // ...
}

接受你之前问题的更多答案,从我这里得到答案。那么?(似乎你在寻求答案方面很快,但在说出答案是否解决了你的问题方面却很慢)。