Standardize: Convert 7 high-priority $conn->query() to prepared statements

Converted queries in:
- functions.php:
  * getTripCount() - Hardcoded query
  * getAvailableSpaces() - Two queries using $trip_id parameter (HIGH PRIORITY)

- blog.php:
  * Main blog list query - Hardcoded 'published' status

- course_details.php:
  * Driver training courses query - Hardcoded course type

- driver_training.php:
  * Future driver training dates query - Hardcoded course type

- events.php:
  * Upcoming events query - Hardcoded date comparison

- index.php:
  * Featured trips query - Hardcoded published status

All queries now use proper parameter binding via prepared statements.
Next: Convert remaining 15+ safe hardcoded queries for consistency.
This commit is contained in:
twotalesanimation
2025-12-03 19:38:18 +02:00
parent 84dc35c8d5
commit 2544676685
6 changed files with 58 additions and 41 deletions

View File

@@ -1,18 +1,21 @@
<?php
$headerStyle = 'light';
<?php
$headerStyle = 'light';
include_once('header.php');
// SQL query to fetch dates for driver training
$sql = "SELECT course_id, date FROM courses WHERE course_type = 'driver_training'";
$result = $conn->query($sql);
$stmt = $conn->prepare("SELECT course_id, date FROM courses WHERE course_type = ?");
$course_type = 'driver_training';
$stmt->bind_param("s", $course_type);
$stmt->execute();
$result = $stmt->get_result();
?>
<?php
$pageTitle = 'Course Details';
$breadcrumbs = [['Home' => 'index.php']];
require_once('components/banner.php');
<?php
$pageTitle = 'Course Details';
$breadcrumbs = [['Home' => 'index.php']];
require_once('components/banner.php');
?>
<!-- Page Banner End -->