PHP, error making query

Asked

Viewed 72 times

-1

My problem is, I’m looking for a query, but I’m not getting all the records, and this is what I’m not getting. I’ll change SQL later, so I left it like this to test. Can someone help me??

this is the Error

WARNING: Mysqli_query() expects parameter 1 to be mysqli, string date in /home/u777508079/public_html/testeConsultar.php on line 19

 <?php

$hostname_conexao = "************";
$username_conexao = "***********";
$password_conexao = "***********";
$database_conexao = "*************";

$sql3 =  mysqli_connect($hostname_conexao, $username_conexao, $password_conexao, $database_conexao);

//$matricula = $_POST['matricula'];   AND morador.id_pessoa = $matricula
$querybanco = mysqli_query( $sql3, "SELECT placa FROM veiculo,morador WHERE morador.id_pessoa = veiculo.id_pessoa  ");

$dados = mysqli_fetch_assoc($querybanco);

$placa2 = $dados['placa'];

$link = "SELECT placa FROM veiculo,morador WHERE morador.id_pessoa = veiculo.id_pessoa";

if ($result = mysqli_query($link, $sql3)) {
    while ($row = mysqli_fetch_assoc ($result)){
        echo $row["placa"];
        echo ",";
    }
}




?>  
  • 1

    Those credentials are right?

  • are yes! on the other pages of the program works

  • And will you leave this information in the post? So anyone can access?

  • valeu man, I didn’t even stop to think =)

  • @Igormatsumoto other than forums, on this site there is no need to add SOLVED in the title. Although the question is closed, you can still accept the answer given by clicking on v to the left of it. Visit [tour] to know how the site works.

1 answer

1


The problem is that its parameters are reversed, change as follows:

if($result = mysqli_query($sql3, $link)) {
    //...
}
  • Valeuman !! It worked

  • Great, consider marking the answer as correct if it helped! =)

  • ixi, I thought I changed the title, well, thanks for warning (y)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.