——————————————————————————–
I have a PHP code, which is to add some data to the MySQL database by the form method; follow by clicking the “submit” botton, the data is added successfully, and the this newly added data is to be writen to a text file:
[code=php]$id=mysql_insert_id();
if($typeid == ‘1’ && $catid == ‘1’ )
{
$filewrite1 = $typeid.” “.$catid.” “.$URL.” “.$title.” “.$author.” “.$publish_date.” “.$content;
$Text1 = “id”.$id.”txt”;
$file1 = “text by PHP/1business_1product/”.”1business_1product_”.$Text1;
if(!function_exists(‘file_put_contents’)) {
function file_put_contents($file1, $filewrite1, $file_append = false)
{
$fp = fopen($file1, ($file_append ? ‘w+b’ : ‘a+b’));
if(!$fp) {
trigger_error(‘file_put_contents cannot write in file.’, E_USER_ERROR);
return;
}
fputs($fp, $filewrite1);
fclose($fp);
}
}
else
$filecreate1 = file_put_contents($file1,$filewrite1);
}
Currently, the directory “text by PHP/1business_1product”, containes some text files naming as “1business_1product_id2.txt”, etc. Therefore the newly added text file to this directory will have a similar file name with different “id”.
However, this PHP code is not writing the text file at all, without any error mesage. It seems to stop at the line of “if(!function_exists(‘file_put_contents’))”, and hence it does not excute the “function file_put_contents”…
Could any one help me debug the problems?
Thank you very much!
P.S.: I have another PHP code to write all data from MySQL to text files, using the same function, and it works well.