jigsawsoul Posted January 23, 2010 Share Posted January 23, 2010 does anyone know my problem?? $occurrenceid = $row['occurrence_id']; $result4 = "SELECT COUNT(*) FROM web_attendance WHERE occurrence_id = '$occurrenceid'"; $row4 = mysql_fetch_assoc($result4, MYSQL_NUM) or die (mysql_error()); echo $row4[0]; Link to comment https://forums.phpfreaks.com/topic/189542-count-rows-in-a-database-problem/ Share on other sites More sharing options...
Mchl Posted January 23, 2010 Share Posted January 23, 2010 I do. You don't know how to ask questions the smart way Link to comment https://forums.phpfreaks.com/topic/189542-count-rows-in-a-database-problem/#findComment-1000472 Share on other sites More sharing options...
wildteen88 Posted January 23, 2010 Share Posted January 23, 2010 You're not processing your query correctly. When processing MySQL queries you need to pass them to the mysql_query function first. You'd then pass the result to one of the mysql_fetch_* functions, eg mysql_fetch_assoc Link to comment https://forums.phpfreaks.com/topic/189542-count-rows-in-a-database-problem/#findComment-1000510 Share on other sites More sharing options...
Andy-H Posted January 23, 2010 Share Posted January 23, 2010 You are using a built in constant with the wrong function. Change mysql_fetch_assoc($result4, MYSQL_NUM); to mysql_fetch_array($result4, MYSQL_NUM); //or mysql_fetch_row($result4); also, you need to run mysql_query on $result4... i.e $query4 = "SELECT COUNT(*) FROM web_attendance WHERE occurence_id = " . $occurenceid; $result4 = mysql_query($query4)or trigger_error(mysql_error(), E_USER_ERROR); $row4 = mysql_fetch_row($result4); echo $row4[0]; Link to comment https://forums.phpfreaks.com/topic/189542-count-rows-in-a-database-problem/#findComment-1000535 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.