Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.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文件中所有值的数据库_Php_Android - Fatal编程技术网

没有';无法获取php文件中所有值的数据库

没有';无法获取php文件中所有值的数据库,php,android,Php,Android,我正在创建一个PHP文件,用于使用POST方法在android设备上发送推送通知。当我在HTML页面上插入值时,数据会进入PHP页面,但我的PHP数组没有获取所有行值。我怎样才能解决这个问题 <?php require "init.php"; $message = $_POST['message']; $title = $_POST['title']; $path_to_fcm='https://android.googleapis.com/gcm/send

我正在创建一个
PHP
文件,用于使用
POST
方法在android设备上发送推送通知。当我在
HTML
页面上插入值时,数据会进入
PHP
页面,但我的
PHP
数组没有获取所有行值。我怎样才能解决这个问题

<?php
    require "init.php";
    $message = $_POST['message'];
    $title = $_POST['title'];
    $path_to_fcm='https://android.googleapis.com/gcm/send';
    $server_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    $sql = "select fcm_token from fcm_info";
    $result = mysqli_query($con,$sql);
    $row = mysqli_fetch_row($result);
    $key = $row[0]; 
    $headers = array('Authorization:key=' .$server_key,
            'Content_Type:application/json');
    $fields = array('to'=>$key,'notification'=>array('title'=>$title,'body'=>$message));
    $payload = json_encode($fields);
    $curl_session = curl_init();
    curl_setopt($curl_session,CURLOPT_URL,$path_to_fcm);
    curl_setopt($curl_session,CURLOPT_POST,true);
    curl_setopt($curl_session,CURLOPT_HTTPHEADER,$headers);
    curl_setopt($curl_session,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($curl_session,CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($curl_session,CURLOPT_IPRESOLVE,CURL_IPRESOLVE_V4);
    curl_setopt($curl_session,CURLOPT_POSTFIELDS,$payload);
    $result = curl_exec($curl_session);
    curl_close($curl_session);
    mysqli_close($con);
?>


where is
while
要从
db
检索所有数据,我是php中的新手,只需告诉我use loop
mysqli\u fetch\u row($result)
从何处获取结果集的一行,因此只需一个条目。您必须循环并执行该命令,直到您读取了所有条目。@Atish请尝试更新代码并确认您在表中的记录不止一条,或者确保您的fcm_标记的格式正确,如长度
$key_array=array();
while ($row = mysqli_fetch_assoc($result)) {
  array_push($key_array,$row['fcm_token']);
}