3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function db_news_restart() { mysql_query("DROP TABLE IF EXISTS news"); mysql_query(" CREATE TABLE news ( id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, header longtext, text longtext, author longtext, lastedit longtext); "); } function db_news_create($header, $text, $author) { $set = array(); $set["header"] = "'" . mysql_real_escape_string($header) . "'"; $set["text"] = "'" . mysql_real_escape_string($text) . "'"; $set["author"] = "'" . mysql_real_escape_string($author) . "'"; $set["lastedit"] = "'" . time() . "'"; mysql_query("INSERT INTO news (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")"); } function db_news_edit($id, $header, $text) { mysql_query("UPDATE news SET header = '" . mysql_real_escape_string($header) . "', text = '" . mysql_real_escape_string($text) . "' WHERE id = '" . mysql_real_escape_string($id) . "'") or die(mysql_error()); } function db_news_remove($id) { mysql_query("DELETE FROM news WHERE id = '" . mysql_real_escape_string($id) . "'") or die(mysql_error()); } function db_news_globalGET($id, $what) { $query = mysql_query("SELECT * FROM news WHERE id='" . mysql_real_escape_string($id) . "'"); $get = mysql_fetch_array($query, MYSQL_ASSOC); return $get[$what]; } function db_news_header($id) { return db_news_globalGET($id, "header"); } function db_news_text($id) { return db_news_globalGET($id, "text"); } function db_news_author($id) { return db_news_globalGET($id, "author"); } function db_news_lastedit($id) { return db_news_globalGET($id, "lastedit"); } ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0