-3

So I want to get a MySQL row count and I keep getting nothing instead. I keep getting the error

"Error: couldn't find the row.". When in fact the row is really there in database.

$sql = "SELECT * FROM users WHERE code = '$promo'";
$result = $conn->query($sql);

if ($result->num_rows > 0){
    $rowhis = $result->fetch_assoc();
} else {
    echo "Error: couldn't find the row.";
    die();
}
false
  • 10,264
  • 13
  • 101
  • 209

1 Answers1

-1

You may request to follow PHP appending string with php variable.Please reffer this get more idea

Here you just change your query like below given

$sql = "SELECT * FROM users WHERE code = '".$promo."'";

Please try this will help you.

Pranav MS
  • 2,235
  • 2
  • 23
  • 50