0

What's wrong with my code?

This is the code: <?php session_start(); $db = mysqli_connect("localhost", "root", "", "authentication"); if (isset($_POST['register_btn'])) { session_start(); $username=mysql_real_escape_string($_POST['username']); $email=mysql_real_escape_string($_POST['email']); $password=mysql_real_escape_string($_POST['password']); $password2=mysql_real_escape_string($_POST['password2']); if ($password==$password2) { $password=md5($password); $sql="INSERT INTO users(username, email, password) VALUES('$username', '$email', '$password')"; msqli_query($db, $sql); $_SESSION['message'] = "You are now logged in"; $_SESSION['username'] = $username; header("location:game.html"); } else{ $_SESSION['message'] = "The two passwords do not match"; } } ?> When I open in localhost show me this error: Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in C:\Users\Paul\Downloads\desktop\paul\htdocs\registration form\register.php:5 Stack trace: #0 {main} thrown in C:\Users\Paul\Downloads\desktop\paul\htdocs\registration form\register.php on line 5

1st Aug 2020, 6:27 AM
Paul Hoha
Paul Hoha - avatar
9 ответов
+ 2
Try mysqli_real_escape_string() instead, I noticed you use mysqli.
1st Aug 2020, 6:30 AM
Ipang
0
I think you should link your code for better response
1st Aug 2020, 6:30 AM
Divya Mohan
Divya Mohan - avatar
0
What did you say didn t functioned the problem in the same whan I finish to complete the email password and username and when I press the button register it shows me that error
1st Aug 2020, 6:46 AM
Paul Hoha
Paul Hoha - avatar
0
Okay
1st Aug 2020, 6:52 AM
Ipang
0
In the header file is a game but maybe this is the problem
1st Aug 2020, 6:54 AM
Paul Hoha
Paul Hoha - avatar
0
Is not a problem with the game fron header file is a problem with this code buy i don t know what s wrong this is the sintax: $username=mysql_real_escape_string($_POST['username']);
1st Aug 2020, 7:10 AM
Paul Hoha
Paul Hoha - avatar
0
thanks for everyone I obtained a good code at least
1st Aug 2020, 8:46 PM
Paul Hoha
Paul Hoha - avatar