Hi,
I got a small problem here, usually I fetch information from a database, but in this case I have choosen to read information from a .dat file.
Here a small description:
help_design.php = the page where the faq are displayed in plain html, with all a unique id as hyperlinks.
layout.css = not important in this case, just a css file.
design.dat = the file with the answers.
Structure like this:
1|VRML is not supported
2|You are right about that
3|...
Etc.
Now I get this error:
"Sorry couldn't find the answer."
Which is strange, because the file is there, I have set the permissions to 777 and the id is ok.
I think it's my script?
I hope anyone can tell me what I am doing wrong.
Thanks in advance.
<?php
include("/home/blablabla/bla/layout.css");
if (isset($GET['id']))
{
$datfile = sprintf('/home/blablabla/bla/%u.dat', $GET['id']);
if (file_exists($datfile))
{
show_detailed($datfile);
}
else
{
echo"<META HTTP-EQUIV=\"refresh\" CONTENT=\"3; URL=http://www.mysite.com/help_design.php?<?=SID?>\">";
echo"<center><a href=\"$HTTP_REFERER\">Sorry couldn't find the answer.</a></center>";
exit;
}
}
else
{
echo"<META HTTP-EQUIV=\"refresh\" CONTENT=\"3; URL=http://www.mysite.com/help_design.php?<?=SID?>\">";
echo"<center><a href=\"$HTTP_REFERER\">Sorry please try again later.</a></center>";
exit;
}
function show_detailed ($file) {
$arr = file('/home/blablabla/bla/design.dat');
foreach ($arr AS $line)
{
$line = trim($line);
list($id, $answer) = explode('|', $line);
printf('<li><a href="help_design.php?id=%u">%s</a><br>', $id, $id, $answer);
print "\n";
}
}
?>