perhaps the PATH is not properly set for the user ID of PHP
(which is probably the user ID of the Apache web server
you're running), which is why it didn't execute properly?
Or you may want to explicitly qualify where to dump the
trial.g3 file, like /home/myusername/public_html/trial.g3.
This way, your command is not ambiguous.