So I am having trouble inserting data into my database. The current error I have is a "No database selected" error but I can't see where the issue is. My code is:
<?php
$con=mysqli_connect("localhost","root","","db_test");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$firstname=$_POST['firstnameReg'];
$surname=$_POST['surnameReg'];
$mypassword=$_POST['passwordReg'];
$email=$_POST['emailReg'];
$result= mysql_query("INSERT INTO tbl_customers (firstname, lastname, email, password) VALUES ('$firstname', '$surname', '$email', '$mypassword'");
echo "$firstname", "$surname", "$mypassword", "$email";
if($result)
{
echo "Success!";
}
else
{
die(mysql_error());
}
mysqli_close($con);
?>
Can you see any errors? I know it's not protected against SQL injection, it's just a test project. Thank you.