Lost novice

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ewa

    #1

    Lost novice

    Hello

    I have inherited a www service after someone, I have problems with PHP
    parts. As I am complete novice. I will be very greatful for your help - I
    did not managed to find an answer myself. My questions are trivial, I guess.

    The service is now being moved to another server (PHP 4) and also I would
    like to run it on my local WAMP (PHP 5) for tests.

    1. There's a directory defined there called php_base, which is the root
    directory of this service. All other file locations are definded as
    $php_base/file. Unluckily php_base is absolute, so I need to change it
    manually each time I want to use other server. Is there a way to make it
    server-indpendent? I found that on my WAMP the default location is service
    root, so I can simply use paths relative service root. However, I guess it
    did not work this way on the old server, because the absolute path has been
    specified. Could you show me a proper way of doing it?

    2. Some php pages take a parameter, that is specified in the URL referencing
    this page.

    In the page body the parameter is referenced as $mypar. Unluckily for some
    reason on my WAMP it is always seen as empty, no matter with what value I
    open the page. I am helpless and could not find any indication in php
    manual.

    Many thanks for your help,

    Ewa

  • micha

    #2
    Re: Lost novice


    Ewa wrote:[color=blue]
    > Hello
    >
    > I have inherited a www service after someone, I have problems with[/color]
    PHP[color=blue]
    > parts. As I am complete novice. I will be very greatful for your help[/color]
    - I[color=blue]
    > did not managed to find an answer myself. My questions are trivial, I[/color]
    guess.[color=blue]
    >
    > The service is now being moved to another server (PHP 4) and also I[/color]
    would[color=blue]
    > like to run it on my local WAMP (PHP 5) for tests.
    >
    > 1. There's a directory defined there called php_base, which is the[/color]
    root[color=blue]
    > directory of this service. All other file locations are definded as
    > $php_base/file. Unluckily php_base is absolute, so I need to change[/color]
    it[color=blue]
    > manually each time I want to use other server. Is there a way to make[/color]
    it[color=blue]
    > server-indpendent? I found that on my WAMP the default location is[/color]
    service[color=blue]
    > root, so I can simply use paths relative service root. However, I[/color]
    guess it[color=blue]
    > did not work this way on the old server, because the absolute path[/color]
    has been[color=blue]
    > specified. Could you show me a proper way of doing it?
    >
    > 2. Some php pages take a parameter, that is specified in the URL[/color]
    referencing[color=blue]
    > this page.
    > http://localhost/mypage.php?mypar=value
    > In the page body the parameter is referenced as $mypar. Unluckily for[/color]
    some[color=blue]
    > reason on my WAMP it is always seen as empty, no matter with what[/color]
    value I[color=blue]
    > open the page. I am helpless and could not find any indication in php
    > manual.
    >
    > Many thanks for your help,
    >
    > Ewa[/color]


    1. as far as i can see, $php_base is a variable that must be defined
    somewhere, but always has the same value. include, or better require,
    some config file at the top of each script where you define your base
    path, so you have to change only one setting every time the value
    changes.

    2. i think register_global s is set to off on your WAMP(check with
    php_info), which means ?mypar=value is not automatically registered as
    $mypar=value. register globals off is good, so don't change the
    setting.
    ?mypar=value becomes $_GET['mypar']= value on your system. you could
    use some editor that supports search/replace over many files to adapt
    your code (i use proton for that - www.meybohm.de - but i don't know if
    an english version is available).

    micha

    Comment

    • micha

      #3
      Re: Lost novice

      i use this:

      require $_SERVER['DOCUMENT_ROOT'].'/config.php';

      you just have to put your config file in the doc root.

      micha

      Comment

      Working...