【发布时间】:2013-12-27 09:05:44
【问题描述】:
这很奇怪,我不知道怎么可能,我在一个小项目上工作的代码是代码
<?php
include 'database/dbconnect.php';
if (!isset($_SESSION['id'])) {
header('location:index.php');
}
$user = json_decode(file_get_contents('https://graph.facebook.com/' . $fbid));
print_r($user);
?>
及其得到的结果..
变量$fbid 在此页面中不是defined,而是出于某些不同目的而在另一个页面中。
但是php 没有显示任何error,给出了结果。我清除了sessions 和cookies 什么都没发生。
dbconnect.php
session_start();
$dbhost="localhost";
$dbuser="uuuu";
$dbpass="pppp";
$dbdatabase="dddd";
mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbdatabase) or die("Connection Failed");
定义了 $fbid 的其他页面
include 'dbconnect.php';
if (isset($_POST['me'])) {
$me = $_POST['me'];
$fbid = $me['id'];
$name = $me['name'];
}
显然这两页没有联系,没有include没有require。两者都在不同的文件夹中
【问题讨论】:
-
你的意思是
dbconnect.php的其他页面? -
其他页面是指哪个页面?其中 $fbid 是完全定义的 .. 你是说你清除了你的会话,以防你这样做了,那么这个页面应该重定向到 index.php 进一步的代码不应该运行 ..
-
不......在那个页面中只有数据库连接......没有别的,我也检查过
-
你得到 a 结果。您是否获得了某些具有特定
$fbid的用户的 结果?你试过var_dump($fbid)吗? -
你怎么称呼“它正在得到结果”?如果 $fbid 为空,则返回一个带有“error”属性的 json 对象。