resolved PHP warning with some random code I found, but am afraid I set myself up for bigger problems...