$abc = @fopen("$DOCUMENT_ROOT/../public_html/zamowienia.txt",'ab');
if(!$abc)
{
echo "<br /><br />Zamowienie Panstwa nie moze zostac przyjete w tej chwili. Prosze sprobowac pozniej.";
}
$ciagwyjsciowy = $CPU."\t".$Cenazamowienia_netto."\t".$Cenazamowienia_brutto."\n";
fwrite($abc, $ciagwyjsciowy);
fclose($abc);
this warning will display
Warning: fwrite(): supplied argument is not a valid stream resource in /home/a6907098/public_html/Sklep/process.php on line 27
What's wrong with the code?
PHP Error Message
Warning: fclose(): supplied argument is not a valid stream resource in /home/a6907098/public_html/Sklep/process.php on line 28
using @ in fopen will make file handler to return 0 errors, which means if your file wasnt opened, there will be no error returned. replace @fopen with fopen.
try this
$abc = fopen("$DOCUMENT_ROOT/../public_html/zamowienia.txt",'a');
if(!$abc)
{
echo "<br /><br />Zamowienie Panstwa nie moze zostac przyjete w tej chwili. Prosze sprobowac pozniej.";
}
else
{
$ciagwyjsciowy = $CPU."\t".$Cenazamowienia_netto."\t".$Cenazamowienia_brutto."\n";
fwrite($abc, $ciagwyjsciowy);
fclose($abc);
}
and see what happened. i hope you will find solution
You get this error because your $abc variable it's " is not a valid stream resource " Maybe something wrong with your path to file.
Try this please:
$abc = fopen("$DOCUMENT_ROOT/../public_html/zamowienia.txt",'ab');
if(!$abc)
{
die("<br /><br />Zamowienie Panstwa nie moze zostac przyjete w tej chwili. Prosze sprobowac pozniej.");
}else{
$ciagwyjsciowy = $CPU."\t".$Cenazamowienia_netto."\t".$Cenazamowienia_brutto."\n";
fwrite($abc, $ciagwyjsciowy);
fclose($abc);
}
I'm sorry but code looks awful :(
Did you mean $_SERVER['DOCUMENT_ROOT']
instead of $DOCUMENT_ROOT
?
Also if you get printed Zamowienie Panstwa nie moze zostac przyjete w tej chwili. Prosze sprobowac pozniej.
Zamowienie Panstwa nie moze zostac przyjete w tej chwili. Prosze sprobowac pozniej.
it means that you got no file pointer so you can try Satish Sharma answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.