PHP的通知:试图让非对象错误的性质 [英] PHP Notice: Trying to get property of non-object error

查看:225
本文介绍了PHP的通知:试图让非对象错误的性质的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用厂AngularJS,剧本

I'm using Factory in AngularJS, The Script is

app.factory('GetCountryService', function ($http, $q) {
        return {
            getCountry: function(str) {
                // the $http API is based on the deferred/promise APIs exposed by the $q service
                // so it returns a promise for us by default
                var url = "https://www.bbminfo.com/sample.php?token="+str;
                return $http.get(url)
                    .then(function(response) {
                        if (typeof response.data.records === 'object') {
                            return response.data.records;
                        } else {
                            // invalid response
                            return $q.reject(response.data.records);
                        }

                    }, function(response) {
                        // something went wrong
                        return $q.reject(response.data.records);
                    });
            }
        };

    });

我的输出响应屏幕截图:

My Output Response Screen Shot:

在这里输入的形象描述

我的PHP脚本:

<?php



header("Access-Control-Allow-Origin: *");

header("Content-Type: application/json; charset=UTF-8");



session_start();


$ip = $_SERVER['REMOTE_ADDR'];

$dbname = "xyzData";
$link = mysql_connect("localhost", "Super", "Super") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");

$uid = "";
$txt = 0;
$outp = "";

$data    = file_get_contents("php://input");
$objData = json_decode($data);

if (isset($objData->token))
    $uid = mysql_real_escape_string($objData[0]->token, $link);
else if(isset($_GET['uid']))
    $uid = mysql_real_escape_string($_GET['uid']);
else
    $txt += 1;

$outp ='{"records":[{"ID":"' . $objData->token . '"}]}';
echo($outp);

?>

我的error_log消息

I got error_log message is

[18-MAR-2016 21点四十零分40秒美国/丹佛] PHP的通知:试图让
  在/home/sample.php非对象的属性。

[18-Mar-2016 21:40:40 America/Denver] PHP Notice: Trying to get property of non-object in /home/sample.php

我都尝试 $ objData-&GT;令牌 $ objData-&GT;令牌[0] 。但我得到了同样的错误通知。请帮助我...

I tried both $objData->token and $objData->token[0]. But I got the same error notice. Kindly assist me...

我试图在邮政<所提供的解决方案href=\"http://stackoverflow.com/questions/22636826/notice-trying-to-get-property-of-non-object-error\">Notice:试图让非对象错误的财产,但不如此,我提出了50点赏金为这个职位。我试图更新我在该职位要求的问题<一href=\"http://stackoverflow.com/review/suggested-edits/11690848\">http://stackoverflow.com/review/suggested-edits/11690848,但编辑被拒绝,所以我贴我的要求作为一个新课题。请帮助我...

I tried the Solution provided in the Post Notice: Trying to get property of non-object error, But it fails so, I raised 50 Bounty Points for this post. I tried to update my requirement in that post Question http://stackoverflow.com/review/suggested-edits/11690848, But the Edit was Rejected so I posted my requirement as a new Question. Kindly assist me...

推荐答案

该AngularJS不发送任何对象,而不是它通过GET元素。

The AngularJS is not sending any Object instead it passes the GET element.

简单地只使用访问值 $ _ GET ['UID']

这篇关于PHP的通知:试图让非对象错误的性质的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆