ik ben bezig met een site waarmee ik tekst uit txt bestanden haal dat werkt prima maar als ik via een link met ../leesgedicht.php?gedicht=test dan geeft hij de error
Warning: fopen(".txt", "r") - No such file or directory in c:\php\www\atessite\leesgedicht.php on line 4
Warning: stat failed for .txt (errno=2 - No such file or directory) in c:\php\www\atessite\leesgedicht.php on line 5
Warning: fread(): supplied argument is not a valid File-Handle resource in c:\php\www\atessite\leesgedicht.php on line 5
Warning: fclose(): supplied argument is not a valid File-Handle resource in c:\php\www\atessite\leesgedicht.php on line 7
Code leesgedicht.php :
<?php
$filename = "$gedicht.txt";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
echo "$contents";
fclose($handle);
?>
Code test.php (pagina met link) :
<?php
$titel = "hallo" ;
$test = "<a href='leesgedicht.php?gedicht=$titel'>$titel</a><br>" ;
echo $test ;
?>
hallo.txt :
Test dit is een test
Warning: fopen(".txt", "r") - No such file or directory in c:\php\www\atessite\leesgedicht.php on line 4
Warning: stat failed for .txt (errno=2 - No such file or directory) in c:\php\www\atessite\leesgedicht.php on line 5
Warning: fread(): supplied argument is not a valid File-Handle resource in c:\php\www\atessite\leesgedicht.php on line 5
Warning: fclose(): supplied argument is not a valid File-Handle resource in c:\php\www\atessite\leesgedicht.php on line 7
Code leesgedicht.php :
<?php
$filename = "$gedicht.txt";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
echo "$contents";
fclose($handle);
?>
Code test.php (pagina met link) :
<?php
$titel = "hallo" ;
$test = "<a href='leesgedicht.php?gedicht=$titel'>$titel</a><br>" ;
echo $test ;
?>
hallo.txt :
Test dit is een test