3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $verbindung = mysqli_connect("server","user","pw"); mysqli_select_db($verbindung,"userdaten"); /* Ermittlung der eigenen ID */ $abfrage = "select userid from accountdaten where username = '" . $_SESSION["username"] . "'"; $ergebnis = mysqli_query($verbindung, $abfrage) OR die("Error: $abfrage <br>".mysqli_error()); $row = mysqli_fetch_assoc($ergebnis); /* Ermittlung der ID des Freundes */ $abfrage2 = "select freundid from freunde where userid = " . $row["userid"] . ""; $ergebnis2 = mysqli_query($verbindung, $abfrage2) OR die("Error: $abfrage2 <br>".mysqli_error()); $row2 = mysqli_fetch_assoc($ergebnis2); $num = mysqli_num_rows($ergebnis2); /* Prüfung, ob man bisher schon Freunde hat */ if($num == 0) { echo "Du hast bisher noch keine Freunde."; } else { /* Ermittlung des Usernamen und den Online-Status des Freundes */ $abfrage3 = "select username, online from accountdaten where userid = " . $row2["freundid"] . ""; $ergebnis3 = mysqli_query($verbindung, $abfrage3) OR die("Error: $abfrage3 <br>".mysqli_error()); $row3 = mysqli_fetch_assoc($ergebnis3); /* Ermittlung der Userdaten, die für die Ausgabe gebraucht werden */ $abfrage4 = "select nation, klasse, Level from userwerte where userid = " . $row2["freundid"] . ""; $ergebnis4 = mysqli_query($verbindung, $abfrage4) OR die("Error: $abfrage4 <br>".mysqli_error()); echo "<table>"; echo "<thead><tr> <th>Name</th> <th>Herkunft</th> <th>Klasse</th> <th>Level</th> <th>Online-Status</th> </tr></thead> <tbody>"; while($dsatz = mysqli_fetch_array($ergebnis4, MYSQL_ASSOC)) { echo "<tr>"; /* Wie kann ich $row3 mit in die while Funktion einbringen? */ echo "<td>" . $row3["username"] . "</td>"; echo "<td>" . $dsatz["nation"] . "</td>"; echo "<td>" . $dsatz["klasse"] . "</td>"; echo "<td>" . $dsatz["Level"] . "</td>"; echo "<td></td>"; echo "</tr>"; } echo "</tbody></table>"; } mysqli_close($verbindung); ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /in/aqmn8:2 Stack trace: #0 {main} thrown in /in/aqmn8 on line 2
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: mysql_connect(): Unknown MySQL server host 'server' (111) Catchable fatal error: Argument 1 passed to mysqli_select_db() must be an instance of mysqli, bool given in /in/aqmn8 on line 3
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Call to undefined function mysqli_connect() in /in/aqmn8 on line 2
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: mysqli_connect() in /in/aqmn8 on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: mysqli_connect() in /in/aqmn8 on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: mysqli_connect() in /in/aqmn8 on line 2