How do I not enter data in the database with mysqli and php?

0

I would like to know if anyone can help me is that I do not want to insert values into the database where the title is the same but I can not. With the code below it always inserts into the database, this filter does not allow to insert data with the same title in the database. Note: I have to use mysqli. Thank you.

function inserirNaTabelaFilmesRegisto(
        $db, //ponteiro pelo qual se faz o acesso à SGBDR
        $titulo, $urlImagem, $hrefAssistir, $categoria, $classificacao
    )
    {

//var_dump($db);
//$db = estabelecerLigacaoSGBDR();
if ($db!==false){
    $select = "select * from  filme where titulo = '$titulo'";
    if($result = $db->query($select)===true) {
 echo "ERRO!<br><br><br><br><br><br><br><br>";
    }else{
    $q = "insert into ".BD.".".TABELA_FILME;
           $q.=" values (null, '$titulo', '$urlImagem', '$hrefAssistir', '$categoria', '$classificacao');";
    $db->query($q);
    $e = mysqli_errno($db);
    $eM = mysqli_error($db);
    echo $eM;
    if ($e===0){
        return true;
    }
    }
}//if
return false;
}//inserirNaTabelaApontamentosRegisto
    
asked by anonymous 28.05.2017 / 03:50

0 answers