Hi
im new to all this coding with php and mysql, im trying to link some textboxes on a sign up page of a html to a table i have in mysql
i was wondering if anyone would be able to check this code for me to see if im going wrong somewhere because im getting a failed to connect to mysql error but im not sure if its my code thats wrong or one of my account details that is wrong thank you
<?php $con=mysqli_connect("mysqlusername","password","database name","table name"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // escape variables for security $title = mysqli_real_escape_string($con, $_POST['title']); $firstname = mysqli_real_escape_string($con, $_POST['firtname']); $surname = mysqli_real_escape_string($con, $_POST['surname']); $email = mysqli_real_escape_string($con, $_POST['email']); $password = mysqli_real_escape_string($con, $_POST['pasword']); $DOB = mysqli_real_escape_string($con, $_POST['dob']); $Add1 = mysqli_real_escape_string($con, $_POST['add1']); $add2 = mysqli_real_escape_string($con, $_POST['add2']); $city = mysqli_real_escape_string($con, $_POST['city']); $post = mysqli_real_escape_string($con, $_POST['post']); $sql="INSERT INTO members (FirstName, surname, email, password, dob, Add1, Add2, postcode, city) VALUES ('$title', '$firtname', '$surname', '$email', '$password', '$dob', '$add1', '$add2', '$city', '$post')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); ?>
so what the code is doing is telling it to log into to mysql account and transfer the content of each of the textboxes into the matching cell in the table