tags:

views:

37

answers:

3

I have strange problem, that don't work on server:

session_start();

$quser = new Quser($_SESSION['$fb_user_id'], $pdo);

but this, seems to be OK:

session_start();

$x = $_SESSION['fb_user_id'];
$quser = new Quser($x, $pdo);

Of course, on localhost first option work fine. What is going on? Is there any restriction about that?

+1  A: 

Because you are using single quotes on your variable array dimension, it's looking for a dimension called '$fb_user_id' rather than your variable.

Have a go with

$quser = new Quser($_SESSION[$fb_user_id], $pdo);
DavidYell
+5  A: 

Because of the different between $_SESSION['$fb_user_id'] and $_SESSION['fb_user_id'].Pay attention to spelling of the variable.

Bang Dao
A: 

You have to enable full error reporting. For instance, you can preppend this to your code:

<?php
ini_set('display_errors', TRUE);
error_reporting(E_ALL | E_STRICT);
?>

As soon as you run your code with these settings, PHP will warn you about the undefined variable your code features ;-)

Álvaro G. Vicario