As long as you give your normal notice of resignation, there should be no problem. The idea is that as long as you give the new employer enough time to hire someone else, then you're fine.
If you are expected to give 1 month notice when resigning, then as long as you tell them you won't be starting at least 1 month before the agreed start date, then there should be no problem.
However, giving only a few days notice is considered unprofessional behavior. How much of a problem depends on how difficult your job is to replace and how professional you need to be. If this is a low-end job, then you'll piss off your prospective employer, but what are they going to do about it?
On the other hand, I do a very specific job and am very difficult to replace, and jobs in my field only come up very rarely - maybe once every 3 months in the country; my current employer and I have agreed a 6 month notice period precisely because of this. I have seen people in similar positions who have pulled out of a job after giving less than appropriate notice, get reported to their professional licensing boards for "unprofessional conduct". But then, in a small field like this, word can get around; I know pretty much everyone else in the country that does a similar job on first-name terms. If there's gossip, like a new kid stiffing an employer (and by extension, their colleagues), then that word would get around quite quickly.