SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 72 of 72
  1. #51
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Helge
    Did you try to remove the slash as i suggested in post #46?

    -Helge
    That did nothing. I've got a good idea. How about you post your exact coding for your test, and I'll see if it works, ok? That could work better, cause if your example doesn't work on my server, then it's obviously not the coding that is wrong, right? Please post your example's coding.
    Content Writing Service - Get custom SEO articles for 10$

  2. #52
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok.

    index.php
    PHP Code:
    <?php // index.php
    error_reporting(E_ALL);
    echo 
    '<h1>This is index.php</h1>';
    echo 
    '<p>The page variable coming from the url is: ' $_GET['page'] . '.</p>';

    switch (
    $_GET['page']) {  
        case 
    'add'
            include (
    'add.php'); 
        break; 
        case 
    'downloads'
            include (
    'downloads.php'); 
        break; 
        default: 
            include (
    'default.php'); 
        break; 

    ?>
    add.php
    Code:
    <h1>Yep!! add.php got included</h1>
    -Helge

  3. #53
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What about the default page?
    Content Writing Service - Get custom SEO articles for 10$

  4. #54
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using your example, here is what I got:

    This is index.php


    Warning: Undefined variable: _GET in c:\apache\www\test\index.php on line 4
    The page variable coming from the url is: .

    Warning: Undefined variable: _GET in c:\apache\www\test\index.php on line 6
    Hello
    Content Writing Service - Get custom SEO articles for 10$

  5. #55
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The warnings is coming because of the error level that is set on top of index.php. I always develop with that set to highest.

    Ok, I've changed something in index.php

    index.php
    PHP Code:
    <?php // index.php
    error_reporting(E_ALL);
    echo 
    '<h1>This is index.php</h1>';

    $self $_SERVER['PHP_SELF'];
    echo 
    "<a href=\"$self\">index</a> | <a href=\"$self?page=add\">add</a>| <a href=\"$self?page=wrong\">errorpage</a>";

    $_GET['page'] = (empty($_GET['page'])) ? 'default' $_GET['page'];

    echo 
    '<p>The page variable is: ' $_GET['page'] . '.</p>';

    switch (
    $_GET['page']) {  
        case 
    'add'
            include (
    'add.php'); 
        break; 
        case 
    'downloads'
            include (
    'downloads.php'); 
        break; 
        default: 
            include (
    'default.php'); 
        break; 

    ?>
    default.php
    Code:
    <h1>This is the default.php</h1>
    -Helge

  6. #56
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can go see your example on my site for yourself:

    http://www.combats.dynu.com/test/index.php
    Content Writing Service - Get custom SEO articles for 10$

  7. #57
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AAAAA!!!!! I'm so confused!!! Is your example online?
    Content Writing Service - Get custom SEO articles for 10$

  8. #58
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  9. #59
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is what my test page is showing:

    This is index.php


    Warning: Undefined variable: _SERVER in c:\apache\www\test\index.php on line 5
    </FONT>index | add| errorpage The page variable is: default.
    This is the default.php


    How come I am getting the undefined variable, while you are not?
    Content Writing Service - Get custom SEO articles for 10$

  10. #60
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did see that.
    And why that is happening is beyond my knowledge. I've never installed/administrated a server so I don't know.

    I've highlighted the $self variable in my page. As you can see it works there.

    I'm sorry. I don't know what to suggest next.

    -Helge

  11. #61
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apache server gurus !!! HELP!
    Content Writing Service - Get custom SEO articles for 10$

  12. #62
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you give us a copy and paste of the line with $_SERVER, as well as the line before and the line after?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  13. #63
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a long thread and I wasn't able to follow it,
    but dragonfly is using php version 4.0.6....
    (dragonfly it that's not true please correct me,
    but I remember I asked that to you sometimes ago and also doing a netcraft to your website still show 4.0.6 )
    That's the reason why he can't access _SERVER, _GET stuffs.
    I can't remember how to access "get" variables under that php version, but php gurus will help you on that.



    :-) pippo
    Last edited by pippo; Mar 28, 2003 at 08:30.
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  14. #64
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Pippo, that did not even occur to me.
    $HTTP_SERVER_VARS is the older array which behaves similarly to $_SERVER, except it is not a superglobal.
    http://us2.php.net/manual/en/languag...predefined.php
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  15. #65
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Deleted post...
    Last edited by dragonfly_7456; Mar 30, 2003 at 05:12.
    Content Writing Service - Get custom SEO articles for 10$

  16. #66
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean by, it is not "superglobal"?
    Content Writing Service - Get custom SEO articles for 10$

  17. #67
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, it works! Haha! Alrighty!
    Content Writing Service - Get custom SEO articles for 10$

  18. #68
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dragonfly_7456
    What do you mean by, it is not "superglobal"?
    It's not available *everywhere*, for example in functions, you have to pass it to the function

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  19. #69
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If anyone is still following this thread. LoL. Here is the end result coding that I used, which I put into the part of my coding, where the pages were to be switched.

    PHP Code:
    <?php
    $file 
    = ( isset($HTTP_GET_VARS['page']) ? $HTTP_GET_VARS['page'] : 'default' ); 
    $file .= ".php"
    $check = @include($file); 
    if (!
    $check

      include(
    'missing.php'); 

    else 
    {} 
    ?>
    Default.php contains the content that is to show up on the index.php page, and missing.php is the content that shows when a file is missing, that was called through a query string.

    Also, if you want, you can change 'page' to whatever you want. 'act' , 'pg', 'file'. Whatever you prefer.
    Content Writing Service - Get custom SEO articles for 10$

  20. #70
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Dragonfly,
    what happen if my server is www.example.com ( your server is www.example.net] ) and my server does not parse .php

    If I call your script using:
    www.example.net/index.php?page=http://www.example.com/bad-guy
    then my file
    http://www.example.com/bad-guy.php
    will be interpreted in your server and that could do serious damages.

    Okay, remote-include must be enabled...
    BTW,
    I'd suggest another approach.

    Maybe an example could be:
    PHP Code:
    <?php


    $pagesList 
    = array( "default""pippo""dragonfly" );


    $page = isset( $HTTP_GET_VARS['page'] ) ? strtolower$HTTP_GET_VARS['page']) : 'default'

    if (
    in_array($page$pagesList) ) {

       include( 
    $page.'.php' ); 



    ?>
    or something like that .


    Andrea
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  21. #71
    SitePoint Member
    Join Date
    Oct 2003
    Location
    Moscow, Russia
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is dragonfly_7456.

    I can't believe I got this to work, but I did it...

    PHP Code:
    <?php 

    $pagesList 
    = array( "default""missing""help" ); 

    $page = isset( $HTTP_GET_VARS['page'] ) ? strtolower$HTTP_GET_VARS['page']) : 'default'

    $check = @include($file); 

    if (
    in_array($page$pagesList) ) { 

       include( 
    $page.'.php' ); 

    }

    elseif (!
    $check

      include(
    'missing.php'); 


    ?>
    1. All pages load from index.php?page=
    2. index.php loads default.php as the default page.
    3. If a page exists but is not in the page list, it will show up as "Missing".
    4. If a page is missing, and is called through index.php?page= you will get a default "Missing.php" page.
    5. Pages that are in the list load correctly under index.php?page=page

    Only problem is, what if my site gets to 100 pages. Will that increase page loading time, or will it still work fine?

  22. #72
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah. Got my account back.

    So, will that cause loading time problems when there is over 100 pages?
    Content Writing Service - Get custom SEO articles for 10$


Bookmarks

Posting Permissions

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