Blank php pages are usually caused by fatal runtime errors, though it could be due to code with bad logic that simply doesn’t output anything. Do you have php’s error_reporting set to E_ALL (it should always be this value) and temporarily set display_errors to ON, preferably both set in the php.ini on your system, so that php would help you by reporting and displaying all the errors it detects?
Next, you always need error handling for statements that can fail. For database statements that can fail - connection, query, prepare, and execute, the simplest way of adding error handling, without adding logic at each statement is to use exceptions for errors and in most cases let php catch and handle the exception, where php will use its error related settings (see the first paragraph above) to control what happens with the actual error information (database statement errors will ‘automatically’ get displayed/logged the same as php errors.) To enable exceptions for errors for the mysqli extension, add the following line of code before the point where you make the database connection -
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
As to the posted code, there are some problems with it -
- Do NOT put external, unknown, dynamic values directly into sql query statements, where any sql special characters in the value will break the sql query syntax, which is how sql injection is accomplished. Instead, use a prepared query. This would be a good time to switch the much simpler and more modern PDO database extension, since it is much easier to use, especially with prepared queries.
- Php has finally removed the ridiculous assumption that undefined constants be treated as quoted strings. $_POST[txtDate] MUST be coded as
$_POST['txtDate']
. This would be producing a php error, with differing results, depending on php version.
- A LIKE comparison, without a wild-card character, is in most cases the same as an = comparison. You should use an = comparison for exact matches.
- A COUNT() query, without a GROUP BY term, will always produce a result set with one row in it. There’s no point in testing the number of rows for this type of query, just fetch and use the $row[“totalSlots”] value. Also, don’t use a loop to fetch data from a result set that you know contains only one row. Just directly fetch that row of data. There’s also no point in the ORDER BY term in this specific query.