Hi, I have error in Unity Console but only " User login failed. Error # " (without number). Could anyone help mi wtih it? I think something is wrong at the end.. Code (CSharp): <?php $con = mysqli_connect('XXX', 'XXXr', 'XXX', 'XXX'); /// check that connection happens if (mysqli_connect_errno()) { echo "1: connection failed"; // error code #1 = connection failes exit(); } $username = mysqli_real_escape_string($con,$_POST["name"]); $usernameclean = filter_var($username, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH); $password = $_POST["password"]; // check if name exists $namecheckquery = "SELECT username, salt, hash, score, gold, D1H FROM players WHERE username = '" . $usernameclean . "';"; $namecheck = mysqli_query ($con, $namecheckquery) or die ("2: Name check query failed"); // Error code #2 - name check query failed if (mysqli_num_rows($namecheck) != 1) { echo "5: Either no user with name, or more than one"; //error code #5 - number of names watching !=1 exit(); } // get login info from query $existinglogininfo = mysqli_fetch_assoc($namecheck); $salt = $existinglogininfo["salt"]; $hash = $existinglogininfo["hash"]; $loginhash = crypt($password, $salt); if ($hash !=$loginhash) { echo "6: Inccorect password" ; // Error code #6 - password does not hash to match table exit(); } echo "\t" . $existinglogininfo["score"]; echo "\t" . $existinglogininfo["gold"]; echo "\t". $existinglogininfo["D1H"]; ?>
On line 20 you have an extra semicolon. Also, I would recommend using prepared statements instead of what you are doing now. Finally, I would place the credentials to your database in a configuration file as opposed to having them written in inline the source code (this would help protect the credentials incase something goes wrong and the plain PHP code is printed out.