Shouldn’t the magnetic field of a solenoid be affected by length? I’m in an electricity and magnetism course right now and I literally can’t find an answer to this question, so I was wondering if someone could help.
In order to find the magnetic field inside a solenoid people use Ampère's law. Say you had 2 solenoids, one with 5 turns and one with 7 turns. Both have the same current and turn density. Based on the knowledge that each turn creates a magnetic field, it would make sense that at the center of the 7 turn solenoid there is a stronger magnetic field because of more turns contributing to the magnetic field at that point.
But, if you use Ampère's law and enclosed, say, the middle 3 loops of each solenoid, in the equation
$$\oint \mathbf B \cdot \mathrm d\mathbf l = \mu_0 I$$
the $\mathrm d\mathbf l$ and $I$ enclosed would ultimately be the exact same because the Amperian loop is the same length and the same amount of turns penetrate the loop. This means the magnetic field strength B should be the same for the 2 solenoids.
Am I missing something? Does the strength of a solenoid depend on the length or not?
 A: The field at the center does depend on the total number of turns, but that is only relevant for a solenoid of finite length.  Meanwhile, Ampère's Law only applies to a solenoid of infinite length.  That's because, to turn the general integral form of the law into an equation from which you can solve for $B$, there must be enough symmetry for you to simplify the integral expression.  That means that (a) the current distribution must have some inherent symmetry, and (b) you must choose an Amperian loop that takes advantage of that symmetry.  For the infinite solenoid, an appropriate loop is illustrated in the second to last slide of this document:
https://www.classe.cornell.edu/~liepe/webpage/docs/Phys2208_lecture18.pdf
It is a rectangle with one side along the solenoid axis, and the parallel side outside the solenoid.  Thus the other two sides pass through the "wall" of the solenoid and are perpendicular to its loops.  Basically, by symmetry alone, you can deduce that the magnetic field (a) is everywhere parallel to the solenoid axis, and (b) is constant along the axis or any line parallel to it.  (a) is true because of rotational symmetry, ie. you can rotate the solenoid about its axis without changing the picture, and (b) is true by translational symmetry -- due to its infinite length, you can slide it along its axis without changing the picture.  So the magnetic field must have those same two types of symmetry.  Finally, you can show that the field goes to zero outside the solenoid, and combining these facts means the Amperian integral is zero on all but the axial side, leaving:
$$Bh = \mu_0 I_{enc}$$
where $h$ is the length of the axial side.  Only because you reduced the integral to a simple product, via symmetry, can you now solve for $B$.
But a finite solenoid does not have translational symmetry, so the above method can't be applied.  Instead, in principle, you would have to start from the Biot-Savart law and integrate it to find the formula for the field of a current ring anywhere on its axis, then add up that formula for all the rings in your finite solenoid.  Which will clearly depend on the number of rings.
So in a sense, you're right that you don't have to enclose all the current in order to apply Ampère's Law, but the application of Ampère's Law still depends on the current outside your loop, because that current establishes the symmetry which reduces the integral to a product that can be solved.
