Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Junior Member maddog2002's Avatar
    Join Date
    Mar 2003
    Posts
    7
    Member #
    863
    I have only just started using php and am now stuck a freind helped me get as far as I am. I just transferred my web site to php
    if($page == 'index') {
    ?>
    12 March 2003
    <br>
    Blah Blah Balh
    <?php
    }
    I put the ifs in and it works great but is it possible where the blah blah blah is place a text file for easy updating?what i mean is instead of updating everything in the index.php file i can make a text file called say 'NEWS.txt and teverything in that file will appear where blah blah blah is? is it possible I think it should be simple but like i said i'm new to php.

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    PHP Code:
    if ([i]condition[/i])
    {
    include(
    "/path/to/your/file.txt");

    You need the braces when using include and require, even if it's just one line of code!
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Junior Member maddog2002's Avatar
    Join Date
    Mar 2003
    Posts
    7
    Member #
    863
    thanks this is what i put
    if($page == 'index') {
    ?>
    include(/news);
    }

    and it doesn't work.
    i get this
    Parse error: parse error, unexpected '[' in /usr/local/psa/home/vhosts/rpghideout.co.uk/httpdocs/index.php on line 87
    please help :-(

  5. #4
    Senior Member splufdaddy's Avatar
    Join Date
    Feb 2003
    Location
    Boston, MA
    Posts
    4,488
    Member #
    735
    I'm sort of a noob to php also, but I have been using the php include command and i think I can take a stab at this...experts correct me if I'm wrong, but you need to use the absolute path when referencing "news", so instead of:

    include(/news);

    you need to put:

    include("/usr/local/psa/home/vhosts/rpghideout.co.uk/httpdocs/yourfilenamehere.php");

    hope this helps, give it a shot and an expert will probably be by to correct me if i'm wrong!

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    The quotes are the important part. Also the path is relative to the filesystem, not the URL.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    Junior Member maddog2002's Avatar
    Join Date
    Mar 2003
    Posts
    7
    Member #
    863
    it dont work iv'e updated it correctly
    if($page == 'index') {
    ?>
    include ("news.php");
    <?php
    }

    the news.php is in the same folder i changed it for easier use.

  8. #7
    Junior Member maddog2002's Avatar
    Join Date
    Mar 2003
    Posts
    7
    Member #
    863
    you also said
    PHP Code:
    if ([i]condition[/i]) 
    do i need the
    PHP Code:
    [i][/i
    and cause it doesn't work when i put them in. I just get error messages.

  9. #8
    Senior Member splufdaddy's Avatar
    Join Date
    Feb 2003
    Location
    Boston, MA
    Posts
    4,488
    Member #
    735
    you need to copy exactly what I wrote. Filburt and I both said you need to use the ABSOLUTE PATH.
    Earlier I told you to put in:
    include("/usr/local/psa/home/vhosts/rpghideout.co.uk/httpdocs/yourfilenamehere.php");

    you just told us you put in
    include ("news.php");

    that's not exact. change the yourfilenamehere.php in my earlier post to news.php, and copy that WHOLE line.

  10. #9
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    $50 says that you're not ever setting the page variable. Try this:
    PHP Code:
    if (strpos($_SERVER['PHP_SELF']), "index.php"))
    {
        include(
    "news.php");

    If you don't get an error, then either the if statement isn't right or news.php is empty. If you do get an error like Couldn't open news.php, then you're referencing the wrong file.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  11. #10
    Junior Member maddog2002's Avatar
    Join Date
    Mar 2003
    Posts
    7
    Member #
    863
    it's ok i fixed it
    i ha the put the line above
    PHP Code:
    ?> 
    which i didn't i put it below it works fine now thanks guys.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:40 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com