1. Make sure that php knows the path to your scriptfile and mysql executable.
2. Make sure that your database has proper priveleges granted to the www user.
Like so... do this with ./mysql
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER
ON macimage.*
TO...