You mixed procedural and object oriented styles of MySQLi. This resulted in you trying to use functions like mysqli_query($mysqli) instead of member functions like $mysqli->query() . Your $mysqli is an object, not a resource descriptor.
And you do not perform error checking in your request. If you were, you would realize that you mistakenly used single quotes to separate table and field names rather than backreferences.
$sql = "INSERT INTO `nlcc_ver1`.`tUsers` (`userID`, `userName`, `userPassword`, `userHash`, `user_first_name`, `user_last_name`, `user_corps`, `is_admin`, `is_trg`, `is_sup`, `is_co`) VALUES (NULL, '" . $userName . "', '" . $hash . "', '" . $salt . "', '" . $f_name . "', '" . $l_name . "', '" . $corps . "', '" . $admin . "', '" . $trg . "', '" . $sup . "', '" . $co . "')"; $hostname_Database = "localhost"; $database_Database = "nlcc_ver1"; $username_Database = "root"; $password_Database = ""; $mysqli = new mysqli($hostname_Database, $username_Database, $password_Database, $database_Database); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $result = $mysqli->query($sql); if (!$result) { printf("%s\n", $mysqli->error); exit(); } echo "Query run. Inserted UserID " . $mysqli->insert_id . "<br />";
I highly recommend using the guide as a reference. Itβs clear how to use these functions when you use either the procedural or the object-oriented style of MySQLi.
source share