3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // variable $table_name = 'Rendisk Circular Ikea Delft'; $table = 'esync_tagshistory'; $rows = 250; $data = ""; // connect to the database $connection = mysql_connect('localhost','eSyncExport','Rendisk@2013'); mysql_select_db('esync',$connection); // sending query will collect tag names of selected ewon $result = mysql_query("SELECT ESYNC_TAGS.NAME, _date, ESYNC_TAGSHISTORY.Val FROM ESYNC_TAGSHISTORY INNER JOIN ESYNC_TAGS ON ESYNC_TAGSHISTORY.TAGID=ESYNC_TAGS.ID WHERE ESYNC_TAGS.STATIONID=1 ORDER BY _date DESC LIMIT $rows"); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<h1>{$table_name} last $rows rows</h1>"; echo "<table border='3' cellpadding ='10' <tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } // printing table rows while($row = mysql_fetch_row($result)) { $data = ",['".$row[1]."', ".$row[2]."]".$data; echo "</tr>\n"; echo "<td rowspan ='1'>$row[0]</td>"; echo "<td rowspan ='1'>$row[1]</td>"; echo "<td rowspan ='1'>$row[2]</td>"; //echo $data; } mysql_free_result($result); //echo "</TABLE>"; $data = "['Date', 'Value']".$data; //echo $data; ?> <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ <?php echo $data; ?> ]); var options = { title: '<?php echo $table_name;?>', vAxis: {title: "On/Off"}, hAxis: {title: "Time"}, seriesType: "line", series: {5: {type: "line"}} }; var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["table"]}); google.setOnLoadCallback(drawTable); function drawTable() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Name'); data.addColumn('string', 'Date'); data.addColumn('boolean', 'Value'); dataata.addRows([ ['Rij 1', 'Waarde 1'], ['Rij 2', 'Waarde 2'], ['Rij 3', 'Waarde 3'], ]); var table = new google.visualization.Table(document.getElementById('table_div')); table.draw(data, {showRowNumber: true}); } </script> </head> <body> <div id="table_div"></div> </body> </html> <meta http-equiv="refresh" content="60"> </head> <body> <div id="chart_div" style="width: 100%; height: 700px;"></div> </body> </html>
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/lQVso:9 Stack trace: #0 {main} thrown in /in/lQVso on line 9
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Fatal error: Call to undefined function mysql_connect() in /in/lQVso on line 9
Process exited with code 255.