I wish to have a page that will display a form if there aren't already enough registrations in the database. The following it an outline of how it will be:
<?php
require_once "../scripts/connect_to_mysql.php"; //this works fine
// Count how many records in the database
(1) $sqlCommand = "SELECT * FROM teams";
(2) $sqlCommand = "SELECT COUNT (*) FROM teams";
(3) $sqlCommand = "SELECT COUNT (id) FROM teams";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
(1) $numRegistrations = mysql_num_rows($query); //Count how many rows are returned from the query above
(2) $numRegistrations = $query
(3) $numRegistrations = mysql_num_rows($query);
mysqli_free_result($query);
?>
(Some HTML code, like DOCTYPE, head, start of body tags)
<?php
if($numRegistrations > 35){
echo "Sorry, registrations for this event is at it's maximum.";
}else{
?>
<form blah blah blah>
</form>
<?php
}
?>
(end of body and html tag)
You'll see above there is (1), (2), (3). These are the main 3 that I've been trying, and they match up the $sqlCommand to the $numRegistrations.
What would be the problem with this code? I use wamp server to test, have been using it for ages. Chrome browser to test in.
If I remove the database query, the rest of the page will load.
With the query in there, only the HTML code up until the database query is parsed, so therefore nothing is display on the page.
Please help.
Thanks
Denno