PHP SQL代码未插入数据库

I have asked this before but with a different code and I didn't get an Answer that fixed this so I have got a different code but it has the same problem It doesn't Insert anything into the database.It should Insert You have found a secret game into the secret Column and insert a 1 into the Code column and they should both be in the user's Row.I believe the problem is at if(empty($_SESSION['user'])) { but Dreamweaver gives me syntax errors when i change it.

<?php 
session_start();
    require("common.php"); 

    if(empty($_SESSION['user'])) 
    { 
    echo''; 

        $query_params = array( 
            ':user_id' => $_SESSION['user']['id'] 
        ); 

        $query = " 
            UPDATE users 
            SET 
                secret='You have found a Secret Game!', code='1' 
            WHERE 
                id=:user_id 
        "; 

        try 
        { 
            $stmt = $db->prepare($query); 
            $result = $stmt->execute($query_params); 
        } 
        catch(PDOException $ex) 
        { 
        } 
        $_SESSION['user']['secret'] = $_POST['secret']; 
        $_SESSION['user']['code'] = $_POST['code'];      
    } 
     echo'You found a Secret Game!!';
?> 

If I understand your code right, you are checking if $_SESSION['user'] is empty, but then proceed do use variables which are in $_SESSION['user'], like $_SESSION['user']['id'], which in your case should not even exist?

Maybe your IF clause should be

if (!empty($_SESSION['user']))

It does not make sense as it is right now