Web Analytics Made Easy -
StatCounter a really easy problem (I hope) - CodingForum

Announcement

Collapse
No announcement yet.

a really easy problem (I hope)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • a really easy problem (I hope)

    Hi,

    I feel kind of stupid for posting this, I feel like the answer is right under my nose... Anyway, here it goes:

    I am just trying to dynamically include some html snippets (menu, etc.) in some html pages using include(). No matter what I do (chmod, fiddle w/ the syntax), I cannot get include() to include . Here is my syntax:

    Code:
    <?php include("./includes/header.html")?>
    The includes are in a folder of the same name in the directory of the php page being loaded. Does anyone have any suggestions?

  • #2
    Originally posted by ibnpaul View Post
    The includes are in a folder of the same name in the directory of the php page being loaded.
    what do you mean by that?

    is the included folder in the same directory as your php script? then you need
    PHP Code:
    <?php 
    include('./header.html');
    ?>
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment


    • #3
      No, the includes are in the "includes" directory, which is located in the script's directory. Is that clear?

      Comment


      • #4
        More descriptive subject

        In the future, please use a more descriptive subject when posting a question. See posting guidelines.
        Spookster
        CodingForum Supreme Overlord
        All Hail Spookster

        Comment


        • #5
          Originally posted by ibnpaul View Post
          No, the includes are in the "includes" directory, which is located in the script's directory. Is that clear?
          PHP Code:
          <?php 
          include('./includes/header.html');
          ?>
          then?
          Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

          Comment


          • #6
            Sorry, I don't quite understand your intent behind "then?". This code is not working for some reason that I cannot see. I am just trying to dynamically include some parts of the webpage, such as a menu.

            Comment


            • #7
              What is the file extension of the main file that has the <?php include...?> statement in it?

              If it is not .php then is it likely that the file is not being parsed as PHP code and any <?php ?> tags are being ignored.

              If the above is true, there are two way to correct this -

              1) Rename the file to .php

              2) If this is your web server, you can configure it to parse .htm .html file extensions as PHP.

              If it is already named .php, then ignore the above. Most functions can fail. In this case, the path or permissions might be wrong. Do a little error checking and reporting. Add the following line after the first opening <?php tag in the file -
              PHP Code:
              error_reporting(E_ALL); 
              Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

              Comment


              • #8
                Ok, it is named .php and I did enable error reporting, but I get no printout, I assume the printout would be on the page when it is loaded in the browser, yes?

                Comment


                • #9
                  OK, we have a failure to understand what is going on. If you right click in the browser and view the source code, what do you see? Is this an a public web server that you can post a link to?

                  So that we can get the bigger picture of what is really going on, post all of the main file that is trying to include the other files and post the first one of the files being included.
                  Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

                  Comment


                  • #10
                    Ok, here is the code for "index.php":

                    Code:
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                    
                    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
                    
                    	<head>
                    		<title>The Al-Khaleel Arabic Language and Qur'aan Institute</title>
                    		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    		<link rel="stylesheet" type="text/css" href="../style.css" />
                    		<!--[if IE]><link rel="stylesheet" type="text/css" href="../iestyle.css" /><![endif]-->
                    	</head>
                    
                    	<body>
                    	    <div id="header">
                    			<?php error_reporting(E_ALL);
                    			 include '/includes/header.html';?>
                    		</div>
                    		<div id="margin-container">
                    			<div id="content">
                    		    		<div class="content-header">
                    					<h3><span class="title-float">Welcome</span></h3>
                    			     </div>
                    			     <div class="content-body">
                    					<p>Welcome to the official website of the Al-Khaleel Arabic Language and Qur'aan Institute.  Please use the menu above to navigate.  We hope that you find this website useful and find all the information you require, and if you have any further questions please do not hesitate to contact us.</p>
                    
                    					<p>The Al-Khaleel Institute is located in Cairo, Egypt in an area known as Nasr City. The area is well known for its Arabic language institutes and its large foreign population.</p>
                    
                    					<p>All of our teachers have had years of experience teaching Arabic to foreigners. We use both classical and modern teaching methods.</p>
                    						
                    					<p>We also offer travel services for our students, so they can take a break from studies and see the sights of Egypt.</p>
                    			 	</div>
                    			</div>
                    		</div>
                    		<div id="menu">
                    			<?php include '/includes/top-menu.html';
                    				  include '/includes/i18n-menu.html';
                    				  include '/includes/news.html';?>
                    		</div>
                    	    <div id="footer">
                    			<?php include("/includes/footer.html");?>
                    	    </div>
                    	</body>
                    </html>
                    And here is the code for the first include, "header.html":

                    Code:
                    <h1>The Al-Khaleel Institute</h1>

                    Comment


                    • #11
                      /includes/header.tpl
                      is a file path to a folder called 'includes' in the root directory of the server, it is unlikely this is what you want.
                      ./includes/header.tpl
                      is more likely:
                      you have a folder that contains index.php and a folder called 'includes'. this subfolder contains header.tpl.

                      What confuses me though, is that your css links are to '../iestyle.css', as in a level above index.php?
                      A typical website layout will be something like:
                      Code:
                      /var/www/
                          -index.php
                          -includes/
                              -header.tpl
                              -footer.tpl
                          -css/
                              -styles.css
                              -iestyles.css
                          -index.php
                      the css links will then be
                      ...src="/css/styles.css">
                      (the leading / in this context means web-root, not the 'real' root)
                      and includes will be
                      include 'includes/header.tpl';
                      or
                      include './includes/header.tpl';
                      or
                      include '/var/www/includes/header.tpl';


                      Can you describe your folder structure in a similar way?
                      My thoughts on some things: http://codemeetsmusic.com
                      And my scrapbook of cool things: http://gjones.tumblr.com

                      Comment


                      • #12
                        my root folder is /www, and I then have the project folder /khaleel. I then have inside it the css file, and then one folder for each language that the site is displayed in: /en, /fr, /es, /de. The whole structure is thus:

                        Code:
                        /www
                               -/khaleel
                                          -/de
                                          -/en
                                               -/includes
                                               -index.php
                                          -/es
                                          -/fr
                                -style.css
                        Is that clear?

                        I changed my include statements to this: include 'includes/xxx.html';

                        Thanks!

                        Comment


                        • #13
                          and you're loading in the browser something that looks like:
                          www.domain.com/khaleel/en/index.php
                          (or localhost/khaleel/en/index.php )?
                          My thoughts on some things: http://codemeetsmusic.com
                          And my scrapbook of cool things: http://gjones.tumblr.com

                          Comment


                          • #14
                            Yes, that's right.

                            Comment


                            • #15
                              the folders and files are all readable?

                              What you've provided is correct, as I'm understanding it, so you've either got a server problem, or you're not telling us everything.

                              what do you see if you edit the include to refer to something that doesn't exist? (do you actually get an error, or are they being hidden by something else?)
                              My thoughts on some things: http://codemeetsmusic.com
                              And my scrapbook of cool things: http://gjones.tumblr.com

                              Comment

                              Working...
                              X