Your $db variable is not set correctly. It's likely that the connection failed or something else went wrong.
Do this on the line right before 17:
var_dump($db); exit;
Chances are it will be null or false or some other non-object value indicating that the connection failed. To help more, we'd need to know more about what database connection you're attempting to make (mysql, mysqli, PDO, etc).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…