3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?PHP // ini_set('max_execution_time', 6000); // flush(); // ob_flush(); // ------------------------- DB SETUP ------------------ $dbhost = 'faradaypromo.com:3306'; $dbuser = 'priceles_kst'; $dbpass = 'kst33'; $dbname = 'priceles_kst'; $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname); if ($conn->connect_error) { trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); } // ------------------------- READ LIST ------------------- $wlist = "http://faradaypromo.com/aggr_dom2.txt"; $handle = fopen($wlist, "r"); if ($handle) { while (($line = fgets($handle)) !== false) { pinger($line); } } else { // error opening the file. echo "file io error"; } fclose($handle); // ----------------------------FUNCTIONS ------------------- function pinger($ws){ $ch = curl_init(); $options = array( CURLOPT_URL => $ws, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT_MS => 500, CURLOPT_MAXREDIRS => 10, CURLOPT_NOSIGNAL => 1 ); curl_setopt_array( $ch, $options ); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); echo date('H:i:s')." - ".$ws." ".$httpCode."/n"; if ( $httpCode == 200 ){ write_sql($ws, $httpCode); } curl_close($ch); } function write_sql($ws, $code){ $sql = "INSERT INTO websites (cat,uri,status, time) VALUES ('$wlist','$ws',$code,NOW())"; if($conn->query($sql) === false) { trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR); } else { $last_inserted_id = $conn->insert_id; $affected_rows = $conn->affected_rows; echo " - ok: id ".$last_inserted_id; } } mysql_close($conn);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Class 'mysqli' not found in /in/vjYdl:11 Stack trace: #0 {main} thrown in /in/vjYdl on line 11
Process exited with code 255.
Output for hhvm-3.12.0
Warning: mysql_connect(): Unknown MySQL server host 'faradaypromo.com' (111) Fatal error: Uncaught Error: Database connection failed: Unknown MySQL server host 'faradaypromo.com' (111) in /in/vjYdl:13 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Warning: mysql_connect(): Unknown MySQL server host 'faradaypromo.com' (111) Fatal error: Database connection failed: Unknown MySQL server host 'faradaypromo.com' (111) in /in/vjYdl on line 13
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Class 'mysqli' not found in /in/vjYdl on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: mysqli in /in/vjYdl on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: mysqli in /in/vjYdl on line 11