$time = Date ("y-m-d h:i:s"); $message = $message. "Rn$this->sql". "RN Client IP: $ip". "RN Time: $time". "Rnrn"; $server _date = Date ("y-m-d"); $filename = $server _date. ". txt"; $file _path = "error/". $filename; $error _content = $message; $error _content= "Wrong database, can not link"; $file = "Error"; Set File Save Directory Create a folder if (!file_exists ($file)) { if (!mkdir ($file, 0777)) { The default mode is 0777, which means the maximum possible access rights Die ("Upload files directory does not exist and creation failed"); } } Set up txt date file if (!file_exists ($file _path)) { echo "Build date File"; fopen ($file _path, "w+"); First, make sure that the file exists and can be written if (is_writable ($file _path)) { Open $filename with Add mode, and the file pointer will be at the beginning of the file if (! $handle = fopen ($file _path, ' a ')) { echo "Cannot open file $filename"; Exit } Write the $somecontent to the file we opened. if (!fwrite ($handle, $error _content)) { echo "cannot be written to the file $filename"; Exit } echo "File $filename write Success"; echo "--Error Record saved!"; Close File Fclose ($handle); } else { echo "File $filename not writable"; } } else { First, make sure that the file exists and can be written if (is_writable ($file _path)) { Open $filename with Add mode, and the file pointer will be at the beginning of the file if (! $handle = fopen ($file _path, ' a ')) { echo "Cannot open file $filename"; Exit } Write the $somecontent to the file we opened. if (!fwrite ($handle, $error _content)) { echo "cannot be written to the file $filename"; Exit } echo "File $filename write Success"; echo "--Error Record saved!"; Close File Fclose ($handle); } else { echo "File $filename not writable"; } } } |