View Full Version : Help with whirlpool connecting to php from SAMP

05/03/2015, 02:39 PM
Ok, Dont know hwy my previous thread got closed as this does have to do with SAMP.

and I have seen other UserCP on here before


So I used a print_r on my hash to make sure it was hashing the same as the Key in teh SAMP Db and it is.. YEt it still will not connect me and give me the error in my query.

I know I am connect to the DB because I used that echo and it does output correctly


$con = mysqli_connect('###', '###', '###', '###');
if(mysqli_connect_errno()) {

echo 'Failed to Connect to MySQL' . mysqli_connect_errno();
} else {

echo 'Connected just fine!';
echo '<br>';

if(isset($_POST['submit'])) {


$user = $_POST['username'];
$zone = $_POST['password'];
$pass = strtoupper(hash("whirlpool", $zone));

//Just quickly printing to check its the same as the DB ** It is.


$query = mysqli_query($con, "SELECT * FROM accounts WHERE Username = '$user' AND Key = '$pass'") or die("Can not query the DB");
$count = mysqli_num_rows($query);

if($count == 1) {

$_SESSION['username'] = $user;

header('Location: members.php');
} else {

echo 'Username and Password do not match! Try Again';



This is the password the PHP prints

344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BB D1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB4 48194B9305311AFF038A834A079F

This is the password the Db for SA:MP has saved

344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BB D1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB4 48194B9305311AFF038A834A079F

As you can see, They are identical but it still gives me the "Cant Query DB error"

If I remove "AND Key = '$pass'" from my query line though and just check to see if the Username matches.

it all works and loads all of the players info from the SA:MP DB

I need it to work with the password too though.

05/03/2015, 02:42 PM
Dude, write the query like this:

"SELECT * FROM `accounts` WHERE `Username` = '$user' AND `Key` = '$pass'"

Greekz :cool:

05/03/2015, 02:44 PM
Jesus Christ that worked!!!!!

So weird. I have never had to use the tilda key for the query before. Could you tell me why that worked for future reference?!



05/03/2015, 02:49 PM
Could you tell me why that worked for future reference?!
Because Key is a SQL Statement ;)

With the `` you sign, that it should not be a statement, but a field ;)