0
Can someone help me understand why this code is failing to display the genre of the bank?
<div class="first_info">
<?php
$vide = $_GET['i'];
include "core/home/database.php";
$consultaGe = "SELECT * FROM generos WHERE id='$vide'";
$conGenre = $mysqli->query($consultaGe) or die (@mysqli_error());
?>
<strong>Generos:</strong>
<?php while($gene = $conGenre->fetch_array()){ ?>
<div>
<h5 class="cop_genre" value="<?php echo $gene['id'];?>"><?php echo $gene['genre']; ?></h5>
</div>
<?php } ?>
If I take the WHERE id='$vide'
Alas he displays, but he displays all the generous, and not only his. What is wrong there?
This answers your question? Query to PHP database with WHERE does not return value
– tvdias
Do not concatenate the values directly into the query, as this leaves the application vulnerable to SQL Injection attacks. Read more about it here: https://answall.com/q/9734/112052
– hkotsubo
while is swallowing H5 and don’t know why
– Vinicius Aquino
Just to clarify, in the URL called you are including the parameter "i"? For example
https://example.com/index.php?i=generodesejado
.– Eduardo Bissi
yes it is, so much so that everything else works, the only thing is that it takes the "i" of everything from the movie. Not only of the genre
– Vinicius Aquino
Like, he’s not taking the genre of the genre bank, but the genre number on the film bench, I think that might be the problem, but I still don’t know how to fix it, so if I just put
$v['genre'];
it appears the gender number and not his name, so I tried that code up there, but without success, it does not show the name.– Vinicius Aquino
Could put the table structure
generos
?– Eduardo Bissi
sure I can
– Vinicius Aquino
WHERE id='$vide'
, if$vide
is 1, the query will beid='1'
, but the columnid
is of type INT, does not need the quotation marks. It should beid=$vide
(but better than that would be if you used theprepare
mysqli).– Woss