2015-09-23 5 views
-2

В настоящее время я работаю над веб-сайтом, на котором я пытаюсь добавить ссылки заголовка и меню рекурсивно на каждую страницу с помощью команды include PHP. Всякий раз, когда я пытаюсь запустить определенный файл PHP как include, он не отображается. Когда я запускаю его по требованию, страница загружается пустым.PHP include/require not working

После небольшого исследования я нашел наиболее распространенное решение проблемы; убедитесь, что index.php и страницы, которые вы пытаетесь включить, должны иметь расширение .php; которые они делают.

Вот в основном то, что я работаю с: главной страницей сайта: www.humanistsofutah.org (или также известные как index.php) Хоста Xmission веб-хостинг. openbased_dir установлен в /var/www/vhosts/humanistsofutah.org/

Файл, который я ссылающийся на PHP код называется Houbodyphp.php

Вот код index.php:

 <!DOCTYPE HTML> 
    <html> 
    <head> 
    <?php 
    $INC_DIR = $_SERVER["DOCUMENT_ROOT"]."/includes"; ?> 
    <?php include($INC_DIR. "houbodyphp.php"); ?> 

    <title>Humanists, Humanism, and Rational Thinking in Utah</title> 
    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">            </meta> 
    <link href="houart.css" rel="stylesheet" type="text/css/php"> 


    <meta name="keywords" content="humanism, humanist, science, naturalism,  skepticism, non-theism, atheism, atheist, agnosticism, rational, rationalist, freethought, freethinker, scientific method"> 
    </head> 
    <body> 
    <table border="0" cellspacing="0" cellpadding="0" width="97%" summary="Humanists of Utah (Border)"> 
    <tbody> 
    <tr> 
    <td width="20%"> 
    &nbsp; 
     &nbsp; 

А вот что код HouBodyphp.php выглядит следующим образом:

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
     <html> 
     <head> 
     <style> 
      tbody {position: relative} 
     </style> 
      <body> 

   

   <table border="0" cellspacing="2" cellpadding="1" width="100%" summary="Humanists of Utah"> 
       <tbody> 
        <tr> 
       <td align="center" colspan="6" width="50%"><a href="http://humanistsofutah.org/wordpress/"><img width="600" alt="" style="width: 600px;" src="picture_library/UtahbkgLogoCORRECT.png" /></a></td> 
       </tr> 
       <tr> 
       <td align="center" width="50%" colspan="6" rowspan="4" valign="middle" bgcolor="#ffffff" style="white-space: nowrap;"> 
      <div style="text-align: center;"><b><span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><a href="http://humanistsofutah.org/wordpress/what-is-humanism/">What is Humanism? </a>    <br /><br /></span></b> 
      </div> 
      <div style="text-align: center;"><span "="" background-size:="" background-origin:="" background-clip:="" background-position:="" background-repeat:="" initial;"="" style="font-family: Verdana; font-size: 9pt; background-image: initial;"><a href="http://humanistsofutah.org/wordpress/get-involved/upcoming-events/">Meeting Information and Contacts</a>&nbsp;-&nbsp;</span>   <span font-family:="verdana" ;="" font-size:="9pt" background-image:="" initial;="" background-attachment:="" background-size:="" background-origin:="" background-clip:="" background-position:="" background-repeat:="" initial;"=""><a style="font-family: Verdana; font-size: 9pt;" href="search.html">Search HoU Website</a>&nbsp;-&nbsp;</span> <span style="font-size: 9pt; font-family: Verdana;"><a href="http://humanistsofutah.org/wordpress/archivalsample/">Archive</a></span> <span style="font-family: Verdana; font-size: 9pt;">&nbsp;</span> 
      </div> 
      <p style="text-align: center;"><span style="font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><a style="font-family: Verdana; font-size: 9pt;" href="http://humanistsofutah.org/wordpress/membership/our-members/">Our Members</a></span> <span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">&nbsp;-&nbsp;<a href="http://humanistsofutah.org/wordpress/about-2/historical-humanists/">Historical Humanists</a></span> <span style="font-size: 9pt;">&nbsp;-&nbsp;</span><span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><a style="font-size: 9pt;" href="http://humanistsofutah.org/wordpress/media/recommended-reading/">Recommended Reading</a></span></p> 
      <div style="text-align: center;"><a href="http://humanistsofutah.org/wordpress/related-websites/"><span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">Our Favorite Websites</span></a>&nbsp;-&nbsp;<a href="http://humanistsofutah.org/wordpress/related-websites/"> <span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">Links</span></a>&nbsp;-&nbsp;<span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><a href="www.humanistsofutah.org/wordpress">Great Quotes</a></span> 
      </div> </td> 
     </tr> 
     </tbody> 
    </table></td> 

``

Я знаю, что некоторые из этого, вероятно, совершенно неправильно и от основания, и я заранее извиняюсь за это, но я изо всех сил с этим в течение недель и отчаянно нуждаются в помощи.

Спасибо за ваше время,

Eric Уиттакеру

+3

У вас нет косой черты между вашей дорожкой включения и f ile имя. Также включите отчет об ошибках. Если бы вы это сделали, вы бы решили это. –

+1

'includeshoubodyphp.php' не ваша папка? * et voilà * ;-) –

+0

Он должен работать только с включением («houbodyphp.php»); Для чего нужен $ inc_dir? – frosty

ответ

1

Вашего PHP попытается включить файл includeshoubodyphp.php из-за следующий код:

<?php include($INC_DIR. "houbodyphp.php"); ?> 

Добавить / здесь:

<?php include($INC_DIR. "/houbodyphp.php"); ?> 
+0

Большое спасибо за быстрый ответ Правен! К сожалению, это не помогло: ( –

+0

Чтобы дать дополнительную информацию, так как мне нужно добавить этот заголовок на каждую страницу на веб-сайте, я использую следующий URL-адрес в качестве теста (чтобы убедиться, что заголовок отображается на на каждой странице): http://humanistsofutah.org/2013/CCC-Jan-13.html –