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
Share      Blog   Popular

PHPize.online is a free online environment for quickly running, experimenting with and sharing PHP (including Carbon extension for DateTime) and SQL code. You can run your SQL code with PHP code that can use the same DB. For database manipulations you can use pre-defined instances of PDO ($pdo), mysqli ($mysqli) & Laravel query builder ($db)

Copy Format Clear
create table scientist (id integer, firstname varchar(100), lastname varchar(100), password varchar(8)); insert into scientist (id, firstname, lastname, password) values (1, 'albert', 'einstein', 'emc2'); insert into scientist (id, firstname, lastname, password) values (2, 'isaac', 'newton', 'force'); insert into scientist (id, firstname, lastname, password) values (3, 'marie', 'curie', 'glowin'); SELECT * FROM scientist
Copy Clear
Copy Format Clear
<?php $username = 'albert'; $password = '1234'; $query = "SELECT * FROM scientist WHERE firstname = '" . $username . "' AND password = '" . $password . "'"; printf('Query is: %s ' . PHP_EOL, $query); // Run query using mysqli $result = $mysqli->query($query); printf('Result is:' . PHP_EOL); if (mysqli_num_rows($result) === 0) { printf('<nothing>' . PHP_EOL); } else { while (list($id, $firstname, $lastname, $password) = mysqli_fetch_array($result)) { echo "$firstname - $lastname - $password"."\r\n"; } } ?>
Show:  
Copy Clear