0

Any Idea what's wrong? I have spent hours looking at this and can't see it. The connection is fine.

$DB = new mysqli("127.0.0.1", "Account Here", "Password Here", "DB Here", "Port");  
$query = $DB->prepare("INSERT INTO `Users`(`FirstName`, `LastName`, `Email`, `UserName`, `UserNameHash`, `PasswordHash`, `PasswordSalt`) VALUES (?, ?, ?, ?, ?, ?, ?)"); 
$query->bind_param("sssssss", $FirstName, $LastName, $Email, $Username, $EUsername, $EPassword, $Salt); 
if($query->execute()){
        echo "executed <BR />";
}else{
        echo "Failed <BR />";
}
$query->close();
mysqli_close($DB);
echo "complete"; 

Output:

Failed
Complete

it has been suggested I enable errors, which are enabled, and remove the If statement this is the output when I do:

Complete
josh
  • 11
  • 2
  • We can't tell you what's wrong. You must enable error reporting for mysqli and remove the `if` statement around `execute` – Dharman Jul 16 '20 at 18:20
  • Error reporting is enabled, and even without the if statement it fails silently Removing the if statement would give you less info, as without it you wauldn't know the operation was returning false. I think the failure occurs at the point of the `$query = $DB->prepare` but can' see why. – josh Jul 16 '20 at 20:06
  • Did you add `mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);` in your code? – Dharman Jul 16 '20 at 20:08
  • Your mysqli connection code is missing 2/3 of it. You must always enable error reporting and set the charset – Dharman Jul 16 '20 at 20:18
  • @Dharman Thank you, looks like the value `$Salt` is longer than the feild length of `PasswordSalt` – josh Jul 16 '20 at 20:20
  • I pasted a comment above, I know it applies only partially, but you should never store hash and salt separately. If you are using `password_hash` properly then you should store in in a single column of length 255 – Dharman Jul 16 '20 at 20:21
  • @Dharman thanks I am actualy using SHA 512, Not MD5 or SHA 1. – josh Jul 16 '20 at 20:52
  • Please start using `password_hash`. It is 100x better. There is really no reason to try to invent your own login system – Dharman Jul 16 '20 at 20:52
  • @Dharman I will check password_hash out. – josh Jul 20 '20 at 10:20

0 Answers0