The following is a physics problem, but I don't actually care about the physics right now. I just want to set up the integral, which I'm having a difficult time doing (the problem is from the book 2008+ Solved Problems in Electromagnetics):

The law that we want to use: $$\vec{B} = K \int_C \frac{d\vec{l} \times \vec{r}}{|\vec{r}|^3}$$ $K$ is some constant. $C$ is the wire. $d\vec{l}$ is an infinitesimal length along the wire, and $\vec{r}$ is a displacement vector; where we're calculating $B$. Here's how I'm doing this:
If we define the wire to be $\hat{x}$ where $\hat{y}$ points to the right, then $d\vec{l} = dx ~ \hat{x}$. Any given displacement vector is just $x ~ \hat{x} + y ~ \hat{y} + z ~ \hat{z}$. Then, $d\vec{l} \times \vec{r} = zdx~\hat{y} + ydx~\hat{z}$... right?
So the thing we're integrating is $\displaystyle \int_{L_0}^{L_1} \frac{zdx~\hat{y} + ydx~\hat{z}}{(x^2 + y^2 + z^2)^{3/2}}$ ... ... right?
Since we're just concerned with the 2-D square, $z = 0$ in the displacement vector (because the square is on the xy-plane), so we have: $\displaystyle \int_{L_0}^{L_1} \frac{y}{(x^2 + y^2)^{3/2}}dx ~\hat{z}$ ... ... ... right?
This integral evaluates to: $$-y {\left(\frac{\sqrt{L_{0}^{2} + y^{2}} L_{0}}{L_{0}^{2} y^{2} + y^{4}} - \frac{\sqrt{L_{1}^{2} + y^{2}} L_{1}}{L_{1}^{2} y^{2} + y^{4}}\right)}$$
... but I don't think that is right. Am I setting up the integral correctly?
I tried to minimize the physics (to keep it as math as possible). I've been doing integrals for years, and still have a really difficult time setting up what should be even a basic integral—and it's really, really discouraging. I still feel like I have no clue what I'm doing. :/
As my last comment above indicates, the issue was a physical one: The magnetic field is produced by the entire wire, not just the portion parallel to the square. (You certainly could have examples where the wire is of finite length, and then the equation you provided would be correct.) Consequently the correct integral is
$$\displaystyle \int_{-\infty}^{\infty} \frac{y}{(x^2 + y^2)^{3/2}}dx =\frac{2}{r}$$
as may be shown by a $x=y\tan \theta$ substitution. (Note that this substitution represents the angle between the $y$-axis and $\vec{r}$.)
Returning to the physics context, this gives a magnetic field of $B=\mu_0 I/(2\pi r)$. We can check that this is consistent with Ampere's law: Take an Amperian loop of radius $r$ which winds around the wire. Since $\vec{B}\parallel d\vec{l}$ for the line element of the loop, the circulation is simply $\oint \vec{B}\cdot d\vec{l}=\oint\left(\dfrac{\mu_0 I}{2\pi r}\right) dl=\mu_0 I$ since the circumference is $2\pi r$. But this is exactly what is required by Ampere's law! (Note that you could have deduced $B$ in this manner by making use of the rotational symmetry.)