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.
Results 1 to 13 of 13

Thread: $ don't display

  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    $ don't display

    I am just starting out in php. I got phpinfo to display. no problem. However, moving on I went thru some exercises in a beginner php book and I am stuck. The problem is I can't get $variable to display.
    for ex in my php script

    <?php

    ECHO "<BR><B>Browser: </B> $HTTP_USER_AGENT";

    ?>

    This is the result.
    Browser:

    The $ don't show. I tried using forms and have the variable- what the user type-in the text field display on another php script. By the same results. Nothing under the $

    I am using Apache1.3.22
    php4.2.2
    How I installed. (cgi binary)
    php.ini in windows/system
    added script alias code in my conf file

    Anyone who can help me is the master!

    Christian

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Newer versions of PHP default to having register globals set to off. That means the easy syntax of $HTTP_USER_AGENT doesn't work.

    You'd need - either

    $_SERVER['HTTP_USER_AGENT'];
    or
    $HTTP_SERVER_VARS['HTTP_USER_AGENT'];

    I think.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try them but to no avail? Any other suggestion? Thanks

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    some variables are not available to php running as a CGI - you would be better off (in lots of ways) to run PHP as a module.

    that said, $_SERVER['HTTP_USER_AGENT']; or $HTTP_SERVER_VARS['HTTP_USER_AGENT']; as posted by Ökii should work regardless...

    errr if PHP is indeed running I am unsure why this is occurring,

    try this script and tell us what you get (if anything)

    <?
    while(list($key,$var)=each($HTTP_ENV_VARS)){echo "$key , $var<br>";}
    ?>

    the CGI variables available to you should show up in there somewhere
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    COMSPEC , C:\\WINDOWS\\COMMAND.COM
    DOCUMENT_ROOT , c:/apache group/apache/htdocs
    HTTP_ACCEPT , image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
    HTTP_ACCEPT_CHARSET , iso-8859-1,*,utf-8
    HTTP_ACCEPT_ENCODING , gzip
    HTTP_ACCEPT_LANGUAGE , en
    HTTP_CONNECTION , Keep-Alive
    HTTP_HOST , localhost
    HTTP_USER_AGENT , Mozilla/4.71 [en] (Win98; I)
    PATH , C:\\WINDOWS;c:\\windows;c:\\windows\\COMMAND
    REDIRECT_STATUS , 200
    REDIRECT_URL , /lessons/test.php
    REMOTE_ADDR , 127.0.0.1
    REMOTE_PORT , 1763
    SCRIPT_FILENAME , c:/php/php.exe
    SERVER_ADDR , 127.0.0.1
    SERVER_ADMIN , admin@norton.antivirus
    SERVER_NAME , pop3.norton.antivirus
    SERVER_PORT , 80
    SERVER_SIGNATURE ,
    Apache/1.3.22 Server at pop3.norton.antivirus Port 80

    SERVER_SOFTWARE , Apache/1.3.22 (Win32)
    WINDIR , C:\\WINDOWS
    GATEWAY_INTERFACE , CGI/1.1
    SERVER_PROTOCOL , HTTP/1.0
    REQUEST_METHOD , GET
    QUERY_STRING ,
    REQUEST_URI , /lessons/test.php
    SCRIPT_NAME , /php/php.exe
    PATH_INFO , /lessons/test.php
    PATH_TRANSLATED , c:\\apache group\\apache\\htdocs\\lessons\\test.php

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ergo

    $HTTP_ENV_VARS['HTTP_USER_AGENT'];

    should do for you
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #7
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    ok so "HTTP_USER_AGENT , Mozilla/4.71 [en] (Win98; I) " exists (get a decent browser please they are free ! )


    so you are just going to have to use

    <?echo $_ENV['HTTP_USER_AGENT'];?>

    instead of $_SERVER etc & so I assume its a CGI-issue (get php as a module and change that browser )
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #8
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <FORM METHOD="POST" ACTION="p-4-1.php">
    <H2>Contact List</H2>
    <BR>Nickname:
    <BR><INPUT TYPE="TEXT" NAME="Fullname">
    <BR>Full name:
    <BR><INPUT TYPE="TEXT" NAME="Fullname">
    </form>

    above code for html file
    bottom code for php file

    <?
    echo "<BR>Nickname=$_['Nickname']";
    echo "<BR>Fullname=$Fullname";
    ?>

    I get this on browser.

    Nickname=
    Fullname=

    Empty. Why?

  • #9
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    lol sorry Ökii - didnt see you there!
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #10
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    <?
    echo "<BR>Nickname=$_POST['Nickname']";
    echo "<BR>Fullname=$_POST[Fullname]";
    ?>

    + your form code is wrong you have 2 'Fullname' fields
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #11
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I get this from the code:
    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or
    T_NUM_STRING in c:\apache group\apache\htdocs\lessons\p-4-1.php on line 4

    Now I am trying to install as a module instead.
    when I open phpinfo.php to test on netscape.

    I get this:
    you have started to download a file of type application/x-httpd-php

    What is a good browser to download?

  • #12
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    sorry my bad try this...

    <?
    echo "<BR>Nickname=".$_POST['Nickname'];
    echo "<BR>Fullname=".$_POST['Fullname'];
    ?>

    the browser wont affect how PHP renders , but I would suggest if you dont want to use IE that you pop over to mozilla .org and get the latest stable mozilla browser.

    you are getting the download box because your apache config is not right, in your httpd.conf you need something like this...

    LoadModule php4_module c:/php/sapi/php4apache.dll
    AddType application/x-httpd-php .php4 .php .htm .php3
    AddType application/x-httpd-php-source .phps

    thats assuming php4apache.dll is in your sapi folder along with php4ts.dll which needs to be in sapi or /winnt/system32

    +remove your old script-alias stuff
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #13
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I copied and pasted your code to my conf file. I made sure the dlls are in my sapi. Can you tell me are if they are hidden files. Coz when I go to explorer I don't see the php4apache.dll but when I copy the file in the folder. An overwrite box pops up saying the file already exists. Weird.
    I still get the download box when i open phpinfo.php! I try a html doc with 2 textboxs Action to p-10-1.php. Like above FullName and LastName. When I submit this message appeared

    Method Not Allowed
    The requested method POST is not allowed for the URL /lessons/p-10-1.php.
    Apache/1.3.22 Server at pop3.norton.antivirus Port 80
    Am I doing something wrong with install the module? I did not edit php.ini in my window/system. Am I supposed to?


  •  

    Posting Permissions

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