Your iPhone might not charge if the phone overheats, in other cases, the charging ports can be filled with dust particles which is preventing charging, or the charging adapter is not MFi(made for iPhone).