Asked  7 Months ago    Answers:  5   Viewed   38 times

Here is my case:

$sql = 'UPDATE user SET password = ? WHERE username = ? AND password = ?';
if($stmt->prepare($sql)) {
    $stmt->bind_param('sss', $newPass, $_SESSION['username'], $oldPass);
    $stmt->execute();
}

Now, how can I see if the UPDATE query is successfully executed? And more precisely how can I see if the old password and username are correct so that I can store the new password? I've tried by doing this:

$res = $stmt->execute();
echo 'Result: '.$res;

But I always get:

Result: 1

even if the old password is not correct.

 Answers

34

A query which updates no rows is NOT an error condition. It's simply a succesful query that didn't change anything. To see if an update actually did change anything, you have to use mysqli_affected_rows()

Wednesday, March 31, 2021
 
phirschybar
answered 7 Months ago
50

you forgetting the line to fetch the result. fetch() .

try that:

  $stmt->bind_result($first_name, $last_name);
  $stmt->fetch();  // ----- > you forget that line to fetch results.
  $stmt->close();
Wednesday, March 31, 2021
 
Anax
answered 7 Months ago
51

Did you set the exception mode for PDO with:

$DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

Update: check is mysql reserved words, you need to escape it.

$STH = $DBH->prepare('UPDATE accounts SET `check` = :check_amnt WHERE accnt = :user');
Saturday, May 29, 2021
 
Asher
answered 5 Months ago
86

If you want to check if it is empty:

if ([myMutableArray count] == 0) { ... }

If you want to check if the variable is nil:

if (!myMutableArray) { ... }

or:

if (myMutableArray == nil) { ... }
Tuesday, August 10, 2021
 
scessor
answered 3 Months ago
24

In short,

Yes you can. You can do this by using the UUID of the device. If you know the UUID of a device you can match them up from the reported UUID and know which paired device is what.

Something like this:

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

Method getUuidsMethod = BluetoothAdapter.class.getDeclaredMethod("getUuids", null);

ParcelUuid[] uuids = (ParcelUuid[]) getUuidsMethod.invoke(adapter, null);

Now simply compare the retrieved UUID to the devices known UUID( online or on the box).

If they are a match you know what device it is.

Note: most common UUID (scanners, printers, Mice) have the generic UUID 0001101-0000-1000-8000-00805F9B34FB

Read about the getUUID() method, paracable method , Method java class and finally Java.util.UUID.

Thursday, August 19, 2021
 
Andras Zoltan
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :