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 TABLE users ( id SERIAL PRIMARY KEY, -- Auto-incrementing ID (MySQL: AUTO_INCREMENT, PostgreSQL: SERIAL) username VARCHAR(50) UNIQUE NOT NULL, email VARCHAR(100) UNIQUE NOT NULL, password_hash TEXT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); INSERT INTO users (username, email, password_hash, created_at) VALUES ('john_doe', 'john@example.com', 'hashed_password_1', NOW()), ('jane_smith', 'jane@example.com', 'hashed_password_2', NOW()), ('alice_wonder', 'alice@example.com', 'hashed_password_3', NOW());

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

Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $now = Carbon::now()->format('d/m/Y'); printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion()); $pw = md5("447f82970e03db62f6107ef9719a50ff", true); printf($pw); $query = "SELECT * FROM users WHERE username='john_doe' and password_hash='$pw'"; // 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']); // Run query using mysqli $result = $mysqli->query($query); $row = $result->fetch_assoc(); $row_str = implode(", ", $row); ; printf('here %s ' . PHP_EOL, $row_str);
Copy Clear