How to retain the Id for a query in the WHERE clause?

0

I am looking for how to make when the user enters the Id is collected, to later use to show only their information and do mathematical-logical processes.

First I tried to capture the SESSION of the Id with a variable like this: $Id = $_SESSION['Id'] . For then in the clause WHERE can make the condition like this: WHERE registros.Id = "$Id"; And I get the following:

  

Parse error: syntax error, unexpected '$ Id' (T_VARIABLE), expecting ',' or ')' in       C: \ xampp \ htdocs \ TDE \ Pages \ Admins \ Sale_Shop.php on line 63

The important thing is, how can I use that $_SESSION['Id'] when I want?

    
asked by Estiven Cardenas 05.06.2017 в 17:30
source

1 answer

0

I think that there your problem is that you lack a , o ) in a part of your code did not finish the sentence well. If you do not try the following when the user signs in:

session_start();
$_SESSION["id"] = ID_DEL_USUARIO;
//Aquí las demás variables que uses.

When you do the query assign it.

session_start();
$sql = 'SELECT * FROM USERS REGISTROS WHERE REGISTROS.ID = ' $_SESSION["id"];

If there are errors make an echo to see what comes up:

echo $sql;
    
answered by 05.06.2017 в 20:04