0
I can’t find a value in the database by a select
using as reference a variable from a cookie:
$query = "SELECT * FROM carrinho WHERE dono = '$dono'";
However, if you search using the variable text,
$query = "SELECT * FROM carrinho WHERE dono = 'd2466de8-ccde-4939-f756-bf427f'";
the desired values are found.
The variable $dono
comes from a cookie: $dono = $_COOKIE["id_user"];
And if so echo
the variable appears the same text (d2466de8-ccde-4939-f756-bf427f)
are you sure if into your browser the cookie exist.
– djva
We are at [en.so], please translate your question.
– Woss
yes the cookie exist if i write echo $_COOKIE["id_user"]; its says d2466de8-ccde-4939-f756-bf427f'
– Ricardo Roque
Echo the $query variable, copy and paste it into the bank to test. See if your php code is processing this $query variable correctly, connects to the database, executes the query and brings the resultset. Iterate by the resultset printing the values on the screen.
– Antonio Alexandre
@Ricardoroque the value parentheses was Voce that added or are in the variable?
– Omni
@Omni not the parentheses ' ' does not leave the variable but even taking does not correct
– Ricardo Roque
I don’t understand why : "SELECT * FROM
carrinho
WHEREdono
LIKE $dono" be different from: "SELECT * FROMcarrinho
WHEREdono
LIKE 'd2466de8-ccde-4939-f756-bf427f'" when giving echo from $dono the result is d2466de8-ccde-4939-f756-bf427f– Ricardo Roque
Is there any way to put your complete database code? Give a
var_dump($dono)
and put here exactly the result without changing anything.– Woss
var_dump result was: string(36) "d2466de8-ccde-4939-f756-bf427fc4f8fa"
– Ricardo Roque
@Anderson Carlos Woss, did he set the cookie to be true across the domain
– user60252
@Ricardoroque put the full code of the script then;
– Woss
the script itself is: http://prntscr.com/feoav3 the creation of the cookie is setcookie("id_user", $id, time() + (10 * 365 * 24 * 60 * 60 * 60), "/");
– Ricardo Roque