0

I have read some other related questions on stackoverflow but none solved my problem. This is my code:

$stmt = $conexion->prepare("SELECT Email, MaxActiv FROM `Keys` WHERE ProdKey = ?");
                $stmt->bind_param('sss', $varKey);
                $stmt->execute();
                //$stmt->bind_result($Email, $MaxActiv);
                $stmt->store_result();
                echo "rows: " . $stmt->num_rows . " - " . $Email;
                //Comprobamos si la key existe (esta comprada)
                if ($stmt->num_rows > 0 ){

but it always returns 0 even if the key actually exists on database

  • 1
    You told your `bind_param` there are 3 `string` values but only require one collumn, take a look at: `$stmt->bind_param('sss', $varKey);` – node_modules Mar 30 '16 at 08:29

1 Answers1

1

your bind param string contains too many chars, 'sss' means it is expecting 3 strings

$stmt->bind_param('sss', $varKey);

should be changed to:

$stmt->bind_param('s', $varKey);
Jester
  • 1,408
  • 1
  • 9
  • 21
  • true, I didn't realise that (copied from old query) let me check if it works now –  Mar 30 '16 at 08:29
  • it worked! thank you and sorry for my blindness –  Mar 30 '16 at 08:31
  • you should try to leave error reporting on to catch these little mistakes :) no problem, if it helped you out don't forget to mark the answer so it doesn't show as unsolved – Jester Mar 30 '16 at 08:31
  • I must wait 10min before marking it as correct –  Mar 30 '16 at 08:32
  • aah, good to know xD no problem! still quite new to being active on stackoverflow ;') have a nice day! – Jester Mar 30 '16 at 08:33