3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName); if ($db->connect_error) { die("Unable to connect database: " . $db->connect_error); } if(isset($_POST['importSubmit'])){ //validate whether uploaded file is a csv file $csvMimes = array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'); if(!empty($_FILES['file']['name']) && in_array($_FILES['file']['type'],$csvMimes)){ if(is_uploaded_file($_FILES['file']['tmp_name'])){ //open uploaded csv file with read only mode $csvFile = fopen($_FILES['file']['tmp_name'], 'r'); //skip first line fgetcsv($csvFile); //parse data from csv file line by line while(($line = fgetcsv($csvFile)) !== FALSE){ //insert member data into database $$db->query("INSERT INTO `table 25` (tipologia, inventario, nordcom, marca, modello, sn, cpu, os, cdr, cdc, urgenza, sede, padiglione, piano, stanza, nome, cognome, telefono, ram, stato, datainstallazione, datadisponibilita, datareso, note) VALUES ('".$line[0]."','".$line[1]."','".$line[2]."','".$line[3]."','".$line[3]."','".$line[4]."','".$line[5]."','".$line[6]."','".$line[7]."','".$line[8]."','".$line[9]."','".$line[10]."','".$line[11]."','".$line[12]."','".$line[13]."','".$line[14]."','".$line[15]."','".$line[16]."','".$line[17]."','".$line[18]."','".$line[19]."','".$line[20]."','".$line[21]."','".$line[22]."','".$line[23]."','".$line[24]."')"); } //close opened csv file fclose($csvFile); $qstring = '?status=succ'; }else{ $qstring = '?status=err'; } }else{ $qstring = '?status=invalid_file'; } } //redirect to the listing page header("Location: import.php".$qstring); ?>
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught Error: Class 'mysqli' not found in /in/FOguc:2 Stack trace: #0 {main} thrown in /in/FOguc on line 2
Process exited with code 255.
Output for hhvm-3.22.0
Notice: Undefined variable: dbHost in /in/FOguc on line -1 Notice: Undefined variable: dbUsername in /in/FOguc on line -1 Notice: Undefined variable: dbPassword in /in/FOguc on line -1 Notice: Undefined variable: dbName in /in/FOguc on line -1 Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/FOguc on line -1 Unable to connect database: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Output for hhvm-3.21.3
Notice: Undefined variable: dbHost in /in/FOguc on line 2 Notice: Undefined variable: dbUsername in /in/FOguc on line 2 Notice: Undefined variable: dbPassword in /in/FOguc on line 2 Notice: Undefined variable: dbName in /in/FOguc on line 2 Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /in/FOguc on line 2 Unable to connect database: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Output for hhvm-3.18.5
Notice: Undefined variable: dbHost in /in/FOguc on line 2 Notice: Undefined variable: dbUsername in /in/FOguc on line 2 Notice: Undefined variable: dbPassword in /in/FOguc on line 2 Notice: Undefined variable: dbName in /in/FOguc on line 2 Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Unable to connect database: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Output for 5.6.0 - 5.6.30
Fatal error: Class 'mysqli' not found in /in/FOguc on line 2
Process exited with code 255.