php problems

LATOFILS

New member
Joined
Apr 24, 2016
Messages
2
I am supposed to create a text file using php my code works perfectly I tried it on xampp but on direct admin I dont get a text file created is it possible I dont have a program that runs php files and if I dont how to get that installed I thought it was a permission problem but that dint work after i changed files to 777
 
Hello,

If a PHP script can not create a file, there might be at least two reasons on that:

1. Wrong permissions. A script running on behalf of apache user tries to create a file in a directory owned by another user.
You tried to set 777 permissions, and it did not help. So this is probably not your case. Unless you set 777 permissions on wrong directory.

2. Wrong file path.Windows and Linux has different paths and this is might be the case. Check path which you specified for file creation.


Usually you can find PHP errors in web-server error logs on Directadmin server.

You might need to add in your script the following code if you want PHP error be shown in a browser:

PHP:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
 
php

Hello
Thanks alot for the prompt response this is what I have as my code to create a new txt scipt

file_put_contents(dirname(__FILE__).'/items.txt', $str, FILE_APPEND);
echo "success";
} else {
echo "error";

if I was using the wrong path what path would I used to reach public_html page
 
Back
Top