Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear
-- Create bookings table CREATE TABLE IF NOT EXISTS bookings ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, email VARCHAR(100) NOT NULL, phone VARCHAR(20) NOT NULL, date DATE NOT NULL, time TIME NOT NULL, guests INT NOT NULL, notes TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php // Format date manually since Carbon might not be available $now = date('d/m/Y'); printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion()); // Define query $query = "SELECT VERSION() as version;"; // Check if PDO connection is available if (isset($pdo)) { try { // Get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); printf('DB version (PDO): %s ' . PHP_EOL, $row['version']); } catch (PDOException $e) { echo "PDO Error: " . $e->getMessage() . PHP_EOL; } } // Check if mysqli connection is available if (isset($mysqli)) { try { // Run query using mysqli $result = $mysqli->query($query); if ($result) { $version = $result->fetch_object(); printf('DB version (mysqli): %s ' . PHP_EOL, $version->version); } else { echo "MySQLi query error: " . $mysqli->error . PHP_EOL; } } catch (Exception $e) { echo "MySQLi Error: " . $e->getMessage() . PHP_EOL; } } // Laravel query builder is likely not available in standard PHP hosting // Checking if it exists before attempting to use it if (isset($db) && method_exists($db, 'select')) { try { $version = $db::select($query); printf('DB version (Laravel Query Builder): %s ' . PHP_EOL, $version[0]->version); } catch (Exception $e) { echo "Laravel DB Error: " . $e->getMessage() . PHP_EOL; } } else { echo "Laravel Query Builder not available" . PHP_EOL; } ?>
Copy Clear