A man was caught by officers throwing away a knife near a Walsall park.
Irfan Mahmood Sanni, aged 38, was arrested in Alexandra Road in the Palfrey area of the town following phone calls to police about alleged drug dealing activity.
Mrs Kelly Crowe, prosecuting, said Sanni, of Rutter Street, was spotted by officers near the entrance to Palfrey Park and he was seen to throw an item.
A folding pen knife was found as a result of a search.
She told Walsall Magistrates Court he had originally pleaded not guilty to the charge, the case had been listed for trial, but he changed his plea.
Sanni admitted possession of a knife blade in a public place at a hearing last month.
Mrs Sheila Hicklin, defending, said her client did not brandish or threaten anyone with the knife.
She said he suffered from a tumour on his optical nerve and had also been diagnosed with Hodgkin’s disease.
The magistrates sentenced Sanni to a 12-month community order to attend probation. He must also attend drug rehabilitation at Lantern House. He was ordered to pay £360 costs and £60 victims’ surcharge. They also ordered the forfeiture and destruction of the knife.