0
i have a database Register two-table Joao and maria containing two columns name and age and I’m wanting to do a query in php I just don’t know if I’m doing it right because I’ve been using database I have the following code:
<?php
$host = 'localhost';
$user = 'devel';
$password = '********';
$database = 'Cadastro';
$connect = mysqli_connect($host, $user, $password, $database) or die(mysqli_error());
$consult = $_GET['q'];
if(isset($_GET['q'])){
$sql = mysql_query("SELECT * FROM `Cadastro` WHERE `nome` LIKE $consult");
echo $sql;
}
else {
echo 'nao foi encontrado nada';
}
?>
I’m not getting any feedback
there is already data in the columns but it is not returning anything
There’s something missing from this code, um
i
in themysql_query()
and pick up the query result with a while &mysqli_fetch_assoc()
– rray
As @rray said:
$result = mysqli_query( $connect, "SELECT * FROM ...
andprint_r( mysqli_fetch_assoc( $result ) )
to see the return. I liked the names of the example :) "João e Maria" are very didactic names for examples here on the site.– Bacco
And before they erase all your DB,
$consult = mysql_real_escape_string( $conexao, $_GET['q'] );
– Bacco
I think my consuta this wrong is not returning anything yet there is some way to know if my consuta was performed successfully?
– user45474
It is not even being performed, it has to correct the serious errors before. Reread the previous comments.
– Bacco