C file execution

for the same C file, i can execute it in terminal successfully but when i use exec(‘./“my c file”’) in php, it can’t run. why is that?? it only run half of my C code and when it comes to fopen –> to open .txt file, it stops there.

likely a permission issue. When you run it as yourself you have adequate permissions, but running it under apache, you might not. What is the owner/group of the file you are trying to open? And if you change the owner/group to www-data does it work?

To see who is the owner/group

ls -la file.txt

To change the owner/group

chown www-data.www-data file.txt

THANKs for pointing it out. I changed it already and fixed my problem. Thank you so much bro. ^^