Pergunta

I know the topic has been treated in many questions, but I could not find the solution. I have read and tried many topics,(like 1, 2) but none seem to work on my page. The echo always returns 0 (while the data is 40)

here is my code:

$BIS = "SELECT COUNT(*) as count FROM Voti 
        WHERE sito='$sito' AND utente='$utente'";

#$topics= mysql_query($BIS); 
#echo $topics['count'];    <- this doesn't work

while($row = mysql_fetch_array($BIS)){
    echo $row['count'];   <- this doesn't work
}


if($topics['count']==0){   <- ever 0
$query = " INSERT INTO `Voti` (`utente`,`sito`,`voto`) 
           VALUES ('$email','$sito', $voto)";
mysql_query($query);
}

Sorry for duplicate entry, but i don't found the error p.s. sorry for my bad english

Foi útil?

Solução

you have not run query try to run with mysql_query() try

$BIS = "SELECT COUNT(*) as count FROM Voti WHERE sito='$sito' AND utente='$utente'";

$topics= mysql_query($BIS); 

while($row = mysql_fetch_array($topics)){

or try for count rows

$BIS = "SELECT * FROM Voti WHERE sito='$sito' AND utente='$utente'";

    $topics= mysql_query($BIS); 
$count = mysql_num_rows($topics);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top