0

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

Community
  • 1
  • 1
Lele
  • 703
  • 3
  • 15
  • 34

1 Answers1

1

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);
Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44
  • thanks for the answer. width: $BIS = "SELECT * FROM Voti WHERE sito='$sito' AND utente='$utente'"; $topics= mysql_query($BIS); $count = mysql_num_rows($topics); echo $count; stamp ever 0 – Lele Apr 08 '14 at 10:11
  • then your query doesn't return any rows please echo your query and check conditions is matched – Rakesh Sharma Apr 08 '14 at 10:13
  • i've just tryed. Witring the query on phpMyAdmin, it give me 40 entryes, not 0 – Lele Apr 08 '14 at 14:14
  • EDIT A very stupid error... I'm Wrong on the variables name -.- thanks very much!! – Lele Apr 08 '14 at 14:39