Check field on the bank

Asked

Viewed 26 times

0

I’m doing a search in the bank to see if the amount sent already exists in it.

This is the function I’m using:

 function buscaSubdominio($conexao, $nome_subdominio){

     $query = "select * from subdominio where nome_subdominio = ('{$nome_subdominio}')";
     return mysqli_query($conexao, $query);
   }

So I’m making this condition on another page:

 $confere = buscaSubdominio($conexao, $nome_subdominio);

 if($confere == null){
   echo "registro inexistente";
 }
 else{
   echo "registro existente";
 }

He gives me back that mistake, you can help me?

 Notice: Undefined property: mysqli_result::$nome_subdominio in C:\xampp   \htdocs\daLuz\subdominio.php on line 8
  • Okay, and what exactly is the problem ? Please explain the situation better. You can’t make a query because the "user" is "outdated" ?

  • I put user undressed because I was going to ask otherwise, but I forgot to change. I will change the title. This is the error that comes, but I will edit: Notice: Undefined Property: mysqli_result:$nome_subdominio in C: xampp htdocs daLuz Subdomain.php on line 8

2 answers

0

Maybe it’s because the variable $nome_subdominio was not defined before being used in the function.

  • he is coming via post

  • Then it would be $_POST['subdominio'] resulting in $confers = searchSubdomain($connected, $_POST['nome_subdominio'');

  • yes @Sumback, but it’s like this I just put the if there, but before I get it in the post and saved in the variable $name_subdominio

  • Oh yes, I get it. Try to give a print_r on the variable to see if it is entering the function with some value and not empty.

  • it returns me this: mysqli_result Object ( [current_field] => 0 [field_count] => 3 [lengths] => [num_rows] => 0 [type] => 0 ), you know what I can do? I program a short time

  • It is not returning any lines ([num_rows] => 0). Try this select right in the bank, if it works but returns empty lines, then it may be that the tables are empty.

Show 1 more comment

0


function buscaSubdominio($conexao, $nome_subdominio){

     $query = "select * from subdominio where nome_subdominio = ('{$nome_subdominio}')";
     $stmt = mysqli_query($conexao, $query);
     $row_cnt = mysqli_num_rows($stmt);

     return $row_cnt;
   }

Browser other questions tagged

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