0
Next, first I would like to know if it is possible to receive from another page, through a session_start()
, value of a variable and apply it in a select.
I’m doing it this way:
At the beginning of the page where I want to add select, I added the session_start()
.
Right after, I added the command echo $_SESSION['user']
further down on the page next to HTML and so on, all right, printed the contents of the screen variable.
Just below in HTML comes select:
select unidade from unidades_administrativas A
join users B on A.id = B.id_unidades
where B.user = '{COMO PASSAR O VALOR de $_SESSION['user'] AQUI???}'
Note: The purpose of this select is to display the unit of the user that is logged in to the system.
So my question is: How to pass the value of this variable to select using PDO?
The following errors occurred after using your code:
Pdoexception: SQLSTATE[42000]: Syntax error or access Violation: 1064 You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right syntax to use near '= 'User 1'' at line 3 in C:wamp www point_electronica add_txt_list_drives.php on line 321
Pass by
$_SESSION['user']
he of the Undefined index?– rray
It simply does not return anything, nor error message.
– Ricardo T