Hello, I was testing to connect my php to mysql database and I’m struggling to connect my config.php and registration.php to the db. It also said that I successfully connected to the database but when I tried to enter the firstname, lastname, etc and checked on the phpmyadmin it doesn’t show there.
Note: I just put “password” on db_pass but actually what I put was the mysql pass, as well as for the db_name.
Well you have the email column set as an integer, that will case an error. And since you are limiting the username to 16 characters, make sure your users know that.
Okay noted, I already changed the email column from integer to Varchar and refreshed the registration page and entered whatever required to do and it still did not recorded to the database.
Looking again, you also have a “ComfirmPassword” column that cannot be null. Since you are not submitting a value to that column, the database is rejecting it.
I checked the form and after clicking sign up, the resulting page had a status code 500, which means it’s definitely a PHP code crash. display_errors should help a lot.
The first argument is the host, the second is the user. You seem to be inserting them in the reverse order.
Finally, I checked the live file and it seems the database password is missing, and you don’t seem to be doing anything with the $charset param. But you should really call mysqli_set_charset as well because the defaults on our server are not that good.
You don’t understand. ini_get() gets default values from the PHP configuration. Instead of using ini_get(), just put the information in quotes, like they are in the parameter. Like this:
And later, you are trying to use $conn object-oriented-ly, and that doesn’t work when you established the connection procedurally. Instead, do it like so:
if (mysqli_connect_error($conn)) {
die("MySQL Error: " . mysqli_connect_error($conn));
}