Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 34
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts

    Include function

    Hi!

    I have tried to include my guestbook with the php include function. However it dosn't work as it should.

    This is my code:

    Code:
    <?php include("guestbook/index.php"); ?>
    But when I then browse the page where it should be included on I get following : http://www.xflightx.port10.com/guestbook_view.php

    The file IS in the same directory and permissions are set. So how would I get around that? I can't see why it can't find it..

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    It's saying it can't find a file named ardgb18.dat. So it would seem the problem is with that file, or with your guestbook code trying to open that file.

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    The file you name is the file which stores all the data for the guestbook (all the comments). I have tried to re-upload it, but it still dosn't work.

  • #4
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that is not a standard include error, can you locate the place where that bit of code is echoed and see what it is trying to do.

    Take it right back to basics, see if you can print your name to the screen with the simplest echo ever. If that works you know it is not a permissions problem or something daft.

  • #5
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Then it would seem the problem is in the included guestbook code. A little hard to say without seeing the code, but possibly a path problem?

  • #6
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $dir = "";
    $root = $_SERVER['DOCUMENT_ROOT'];
    $path = "$root$dir";

    // Get Header Type
    include("$path/includes/header.php");

    If you want to see if the path is correct, echo each part above.

  • #7
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    The problem is that the guestbook is trying to get ardgb18.dat in the current directory, whereas it is actually in your guestbook directory.

  • #8
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Guys, thanks for the replies!

    Mwnciau, u were right. It made a difference to put the file in the same directory (the root actually) as my index page. However isn't it possible to make it work with the file in my "guestbook" folder?

    Also, not it returns some new errors:

    Following is the code for the guestbook file: http://www.xflightx.port10.com/guestbook_view.php (Holy ****, it's too long to be here. I'll just post the code near to the error line:


    Code:
    <?
    session_start();
    $newline = (strtoupper($os) == "WIN") ? "\r\n" : "\n";
    switch ($do) {
    case "":
       $record = file($data_file);
       rsort($record);
       $jmlrec = count($record);
    ?>

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You would need to change this line
    PHP Code:
    $record file($data_file); 
    to something like this
    PHP Code:
    $record file($_SERVER['DOCUMENT_ROOT'].'/guestbook/'.$data_file); 
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #10
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Aerospace, that didn't make a difference (at least not one I can spot)?

  • #11
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by CaptainB View Post
    Aerospace, that didn't make a difference (at least not one I can spot)?
    Which is why we need to see the rest of the code. Find some way to post it here.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #12
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    The site dosn't allow that many letters here...So I have zipped the index.php file with the code. Can be downloaded from here: http://www.xflightx.port10.com/index.zip

    (I hope that's okay?)

  • #13
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    PHP Code:
    //Name of file used to store your entry, change it if necessary
      
    $data_file "ardgb18.dat"
    to this
    PHP Code:
    //Name of file used to store your entry, change it if necessary
      
    $data_file $_SERVER['DOCUMENT_ROOT']."/guestbook/ardgb18.dat"
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #14
    Regular Coder
    Join Date
    Jan 2006
    Posts
    377
    Thanks
    8
    Thanked 1 Time in 1 Post
    Maybe the file needs to be uploaded in ASCII format?

  • #15
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Aerospace, I changed what you said but that showed me more errors + the comments didn't show up. I then changed back with we did in the first post, and now I only have a few errors back + the posts show up.

    You can still see the page here: http://www.xflightx.port10.com/guestbook_view.php

    @ guvenck, how would I do that? I use SmartFTP...Could be the reason?


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •