0

I'm using the following code snippet to select number of rows from students table. But it shows the error "Fatal error: Call to a member function bind_param() on a non-object". In my table 'stacyear' is VARCHAR, and 'courseid' is TINY INT.

$stmt = $mysqli->prepare("SELECT count (*) FROM students WHERE stacyear = ? and courseid = ?");
$stmt->bind_param('si', $acyear, $courseid); 
$stmt->execute();    
$stmt->store_result();
$stmt->bind_result($utype);
$stmt->fetch();
Prasanth
  • 49
  • 7

1 Answers1

2

You're not allowed to have a space between COUNT and (*). Change to

$stmt = $mysqli->prepare("SELECT count(*) FROM students WHERE stacyear = ? and courseid = ?");
Barmar
  • 741,623
  • 53
  • 500
  • 612