php - trying to count all votes from voting table but I get an error on line 153 -
fatal error: cannot use object of type stdclass array in /home/students/gar0349/public_html/project2voting.php on line 153
<?php $totalvotes = ("select count(*) total voting votes >= 0 "); $totalvotesresults = mysql_query( $totalvotes ) or die( "could not total votes " .mysql_error() ); $data = mysql_fetch_object( $totalvotesresults ); echo "<div>total number of votes ". $data['total'] ."</div>\n";; ?>
$data = mysql_fetch_object( $totalvotesresults );
you fetching object need use as
$data->total; echo "<div>total number of votes ". $data->total ."</div>\n";;
Comments
Post a Comment