dsf23223 2016-10-30 00:53
浏览 63

xhr响应中的原因不明的var_dump()

I'm using XmlHTTPRequest objects to call PHP scripts asynchronously, but I am getting the return value of var_dump in the output.

Here's the response text (I've edited out my email):

array(5) {
["UID"]=>
string(1) "3"
["NAME"]=>
string(15) "Henry Kissenger"
["EMAIL"]=>
string(25) "******@*******.com"
["PASS"]=>
string(34) "$1$.nDZEZgZ$QKuE.mhlBPDZ3WdhwkiPC1"
["TITLE"]=>
string(9) "Exchequer"
}
3 | Exchequer | Henry Kissenger | ******@*******.com | 

Nowhere in the PHP script and classes is called, even did a find / replace to ensure it's not being called. The relevant code is below, can't find a var_dump in the lot of it.

getSingleUser.php, being called by xhr obj

<?php
session_start();

$pathUser = __DIR__."/../user/uClass_v2.php";
require $pathUser;

$user = User::withID($_SESSION["UID"]);

echo "$user->ID | $user->title | $user->name | $user->email | ";
?>

uClass_v2.php, relevant functions.

//queries db for user with ID, then returns the instance.
public static function withID($ID)
{
    $instance = new self();
    $instance->loadByID($ID);
    return $instance;
}

//queries the user table using the queryByUID() funct, then fill()s
public function loadByID($ID)
{
    $result = $this->queryByUID($ID);
    $this->fill($result);
}


//queries user table, returns the assoc array.
public function queryByUID($ID)
{
    $this->CON = new mysqli("domain.name","kevin","******","tbd");

    $query = "SELECT * FROM User WHERE UID =".$ID;
    $results = $this->CON->query($query);

    if($results->num_rows > 0)
    {
        return $results->fetch_assoc();
    }

}

#accepts array, performs checks to ensure not empty or not meeting assoc array format required, then sets object properties. 
public function fill(array $row)
{
    //counts number of array elements, to decide if existing user or creating new user.
    $noElements = count($row);

    if($noElements <= 0 || $noElements > 5)
    {
        //return "incorrect # elements";
    }else if($noElements == 4)
    {
        //registering new user, leave UID unset.
        //not sure if isset checks are required. 
        if(isset($row["name"])   && 
             isset($row["title"])&& 
             isset($row["email"])&& 
             isset($row["pass"]))
        {
            $this->name = $row["name"];
            $this->title = $row["title"];
            $this->email = $row["email"];
            // @ below = shut up about salts php7
            $this->pass = @crypt($row["pass"]);
        }
        else
        {
            //return "not all element set.";
        }   
    }else if($noElements == 5)
    {   //existing user, from db row.
        $this->name  = $row["NAME"];
        $this->title = $row["TITLE"];
        $this->email = $row["EMAIL"];
        $this->ID   = $row["UID"];
        $this->pass  = $row["PASS"];
    }else
    {
        //echo "I don't think you should ever see this";
    }
}

This has only happened after moving off my cheap hosting service and on to my own server. Is this a mis-configuration somewhere in my Apache / php.ini?

If this looks familiar at all, let me know, I'm getting very frustrated with this!

  • 写回答

1条回答 默认 最新

  • dongpu1331 2016-10-31 03:40
    关注

    It's no longer doing this, here's the changes I've made.

    • suppressed warnings on start_session, no fix @session_start();

    • commented out every echo, then uncommented them this seemed to fix this, but I can't for the life of me find a reason why. //echo "someString";->echo "someString";

    • several re-starts of httpd, no changes to httpd.conf or php.ini

    If anyone could explain this, I'd be eternally grateful.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?