The prepare()
returns false when you have error in your query.
Check if the table or columns name are correct.
$stmt = $this->con->prepare("INSERT INTO table(name, quantity) VALUES (?,?)");
Use Capital INSERT INTO this should not be the issue though but you can try.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…