Next, first I would like to know if it is possible to receive a value from a variable from another page, by session_start()
, and apply it to a select.
I'm doing it this way:
At the top of the page where I want to add select, I've added session_start()
.
Soon after, I added the command echo $_SESSION['user']
lower down on the page next to HTML and so far, okay, it printed the content of the screen variable.
Just below the HTML comes the 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 user drive that is logged into the system.
So my question is: How to pass the value of this variable to the 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 \ electronic_point \ add_txt_list_units.php on line 321