3v4l.org

run code in 300+ PHP versions simultaneously
<?php session_start(); $host="fenrir"; // Host name $username="x"; // Mysql username $password="x"; // Mysql password $db_name="x"; // Database name $tbl_name="register_users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myBirthDay=$_POST['myBirthDay']; $myEmail=$_POST['myEmail']; echo $_SESSION['myFirstName'], $_SESSION['myLastName'], $myLastName, $myBirthDay, $myEmail; // To protect MySQL injection (more detail about MySQL injection) $myBirthDay = stripslashes($myBirthDay); $myEmail = stripslashes($myEmail); $myBirthDay = mysql_real_escape_string($myBirthDay); $myEmail = mysql_real_escape_string($myEmail); $sql="INSERT INTO $tbl_name (id, firstName, lastName, birthDay, email) VALUES(0, $myFirstName, $myLastName, $myBirthDay, $myEmail);"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ echo "Success."; } else { echo "Wrong Username or Password"; } ?>
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /in/e9XNH:10 Stack trace: #0 {main} thrown in /in/e9XNH on line 10
Process exited with code 255.
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Fatal error: Call to undefined function mysql_connect() in /in/e9XNH on line 10
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
Warning: session_start(): Cannot send session cookie - headers already sent in /in/e9XNH on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/e9XNH:2) in /in/e9XNH on line 2 Fatal error: Call to undefined function mysql_connect() in /in/e9XNH on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Warning: session_start(): Cannot send session cookie - headers already sent in /in/e9XNH on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/e9XNH:2) in /in/e9XNH on line 2 Warning: mysql_connect(): Unknown MySQL Server Host 'fenrir' (0) in /in/e9XNH on line 10 cannot connect
Output for 4.3.0 - 4.3.1
Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cookie - headers already sent in /in/e9XNH on line 2 Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cache limiter - headers already sent (output started at /in/e9XNH:2) in /in/e9XNH on line 2 Warning: mysql_connect() [http://www.php.net/function.mysql-connect]: Unknown MySQL Server Host 'fenrir' (0) in /in/e9XNH on line 10 cannot connect

preferences:
225.73 ms | 402 KiB | 356 Q