3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php //set up the database connection $servername = "192.129.1.209"; $username = "meaadmin"; $password = "Kasten_15&"; $dbname = "typo3mea"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //read the json file content $jsondata = file_get_contents('http://127.0.0.1:8000/api/thesis/?format=json'); //convert json object to php array $data = json_decode($jsondata, true); //insert into mysql table foreach($data->objects as $obj) { $sql = "INSERT INTO mea_thesis(title) VALUES('".$obj->title."')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } $conn->close(); ?>
based on 7tUlZ
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Class 'mysqli' not found in /in/bIf0k:9 Stack trace: #0 {main} thrown in /in/bIf0k on line 9
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Fatal error: Class 'mysqli' not found in /in/bIf0k on line 9
Process exited with code 255.