必要なライブラリクラスは2つの.phpファイルを逃してしまいます。 footer.phpでは、クラス(libraries/Database.php)メソッドが使用されています。require_onceがストリームを開くのに失敗しました:そのようなファイルまたはディレクトリはありません
Warning: require_once(libraries/Database.php): failed to open stream: No such file or directory in D:\PHP\Projects in PHP and MySQL\talkingspace\core\init.php on line 15
Fatal error: require_once(): Failed opening required 'libraries/Database.php' (include_path='C:\xampp\php\PEAR') in D:\PHP\Projects in PHP and MySQL\talkingspace\core\init.php on line 15
init.php:
<?php
// start session since we use it on every page
session_start();
// config file
require_once('config/config.php');
// helper functions
require_once('helpers/db_helper.php');
require_once('helpers/format_helper.php');
require_once('helpers/system_helper.php');
// for autoload of classes
function __autoload($class_name) {
require_once('libraries/'.$class_name.'.php');
}
index.phpファイルが正しく表示さ:
<?php require('core/init.php'); ?>
<?php
// create Topic object
$topic = new Topic();
// get Template class
$template = new Template('templates/frontpage.php');
// assign vars
$template -> topics = $topic -> getAllTopics();
$template -> totalTopics = $topic -> getTotalTopics();
$template -> totalCategories = $topic -> getTotalCategories();
// display template
echo $template;
そのテンプレートファイル
私は受信エラーがこれです
<?php include 'includes/header.php'; ?>
<ul id="topics">
<?php if ($topics) : ?>
<?php foreach($topics as $topic) : ?>
<li class="topic">
<div class="row">
<div class="col-md-2">
<img class="avatar pull-left" src="images/avatars/<?php echo $topic -> avatar; ?>" />
</div>
<div class="col-md-10">
<div class="topic-content pull-right">
<h3><a href="topic.html"><?php echo $topic -> title; ?></a></h3>
<div class="topic-info">
<a href="topics.php?category=<?php echo urlFormat($topic -> category_id); ?>"><?php echo $topic -> name; ?></a> >> <a href="topics.php?user=<?php echo urlFormat($topic -> user_id) ?>"><?php echo $topic -> username; ?></a> >> Posted on: <?php echo formatDate($topic -> create_date); ?>
<span class="badge pull-right"><?php echo replyCount($topic -> id); ?></span>
</div>
</div>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php else : ?>
<p>No topics to display</p>
<?php endif; ?>
<h3>Forum Statistics</h3>
<ul>
<li>Total Number of Users: <strong>52</strong></li>
<li>Total Number of Topics: <strong><?php echo $totalTopics; ?></strong></li>
<li>Total Number of Categories: <strong><?php echo $totalCategories; ?></strong></li>
</ul>
<?php include 'includes/footer.php'; ?>
がうまく機能しますが、同様のテンプレートファイルが2つの他の.phpファイルで失敗します。ここでは1(register.php)です:
<?php require('core/init.php'); ?>
<?php
// get Template class
$template = new Template('templates/register.php');
// assign vars
$template -> title = 'Create an Account';
// display template
echo $template;
とそのテンプレートは次のとおりです。
<?php include 'includes/header.php'; ?>
<form role="form" enctype="multipart/form-data" method="post" action="register.php">
<div class="form-group">
<label>Name<sup>*</sup></label>
<input type="text" class="form-control" name="name" placeholder="Enter Your Name">
</div>
<div class="form-group">
<label>Email Address<sup>*</sup></label>
<input type="email" class="form-control" name="email" placeholder="Enter Your Email Address">
</div>
<div class="form-group">
<label>Choose Username<sup>*</sup></label>
<input type="text" class="form-control" name="username" placeholder="Create A Username">
</div>
<div class="form-group">
<label>Password<sup>*</sup></label>
<input type="password" class="form-control" name="password" placeholder="Enter A Password">
</div>
<div class="form-group">
<label>Confirm Password<sup>*</sup></label>
<input type="password" class="form-control" name="password2" placeholder="Enter Password Again">
</div>
<div class="form-group">
<label>Upload Avatar</label>
<input type="file" name="avatar">
<p class="help-block"></p>
</div>
<div class="form-group">
<label>About Me</label>
<textarea id="about" rows="6" cols="80" class="form-control" name="about" placeholder="Tell us about yourself (Optional)"></textarea>
</div>
<input name="register" type="submit" class="btn btn-default" value="Register" />
</form>
<?php include 'includes/footer.php'; ?>
支援してください。私はいくつかのソリューションを無駄にここに投稿してみました。 XAMPPフォルダはC:\のデフォルトフォルダで、プロジェクトフォルダは別のドライブにあります。
許可の問題がある可能性があります – Mehdi
同じコードが1つの.phpファイル2つの他の人のためではありません。これが問題をピン止めするのに役立つ場合、インストラクターは同じ問題を抱えていたので、彼はテンプレートのHTMLコードを置き換え、問題はなくなりました。 –
init.php?どこに置くべきですか? –