So many StackOverflow posts consist of, "I searched how to do X, I copy and pasted the code from the StackOverflow answer that came up, and it doesn't work for me."
You can usually google a few lines of code and find out where they got it from originally.