3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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 7.0.0 - 7.0.24, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
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.

preferences:
175.61 ms | 402 KiB | 225 Q