I am a beginner in PHP and I know nothing about XML manipulation. I am working on a Google CSE annotation XML shown below:
I don't see anything wrong with your code. I think you have a permission problem.
PHP is running as one of the following two users:
nobody
or possibly www-data
(aka the system user the web server uses)For PHP to run as the user that owns the web root (i.e. you), suexec has to be enabled for PHP. The fact that you can't write to a file with 0644
permissions pretty much says that it is not.
You have two options:
I highly recommend the first over the second. However, you don't always have that choice. If your host (or sysadmin, or whoever) can't or won't enable suexec for PHP, you'll have to give the file 0777
permissions, aka rwxrwxrwx
.
You might want to login via ssh and create the output file using the touch
command first (or directory, if that's what you need via mkdir
), then give it the needed permissions.