[英]PHP Config.php for write to flat file
php代码从表单中获取值并将其写入平面文件。 该代码在本地工作,但是当我将其放置在主机上时,会出现两个错误。 本地实例在目录中不需要config.php,但主机文件则需要。
错误1:指出没有config.php
错误2:我必须指定路径,但是如果
? -我应该在配置文件中放些什么,以便它允许我创建平面文件,或者可以相同的方式引用该文件?
任何帮助,将不胜感激。
码:
<html>
<head>
<title>test</title>
</head>
<body>
<?php
include('config.php');
$user = $_GET["name"];
$message = $_GET["message"];
print("<b>Thank You!</b><br />Your information has been added! You can see it by <a href=savedinfo.php>Clicking Here</a>");
$out = fopen( $_SERVER['DOCUMENT_ROOT'] . '/flatfile/test/' . $user . '.txt', "a" );
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<b>$user</b><br />$message<br /><br />");
fclose($out);
?>
</body>
</html>
错误:
1个
Warning: include(config.php) [function.include]: failed to open stream: No such file or directory in /home/user1/flatfile/sendinfo.php on line 7
2
Warning: include() [function.include]: Failed opening 'config.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/user1/flatfile/sendinfo.php on line 7
您有2种方法:创建config.php或删除包含。
您确定config.php文件位于正确的目录中,可以检查该文件是否存在,然后像这样包含
if (file_exists('config.php')) {
include('config.php');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.