How do I prevent iPhoto from opening every time I plug in my iPhone
You might want to look at this question: How can I prevent iPhoto from opening everytime I plug my iPad/iPhone?

The summary is that Image Capture has an option to change what happens when a camera is attached to the computer.