SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Member lstice's Avatar
    Join Date
    Mar 2003
    Location
    Cincinnati
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $PHP_SELF working funny

    I'm using this line in a script:
    PHP Code:
     printf("<a href=""\"%s\">Add a record</a><br /><br />",$PHP_SELF); 
    (note that Sitepoint is adding 2 quotes in my line (href=""). If I remove them when I edit this message they come back. I can't get rid of them, even if I uncheck Automatically parse URLs.)


    but when I click on the resulting line, it doesn't reload the current page. PHP_SELF is defined as the domain and the directory which contains the current page, but not the current page.

    i.e. it should be defined as http://localhost/lh/dhr.php, since that is the current page, but it is actually defined as
    http://localhost/lh. Why is that?
    Last edited by lstice; May 19, 2003 at 17:27.

  2. #2
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is that REALLY the way your code looks above, or did the BBS mess it all up?

    And if it's not messed up, why don't you use:
    PHP Code:
    echo '<a href="'.$PHP_SELF.'">Add a record</a><br /><br />'
    John

  3. #3
    SitePoint Member lstice's Avatar
    Join Date
    Mar 2003
    Location
    Cincinnati
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP John,
    It's not the way it looks. The BBS is adding 2 quotes.
    I was editing my message when you were posting yours, so look at the original msg to see my new comments. Anyway, I will try your syntax.

  4. #4
    SitePoint Member lstice's Avatar
    Join Date
    Mar 2003
    Location
    Cincinnati
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried your syntax, but it still cuts off the file name.
    Any other ideas?

  5. #5
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try: $_SERVER['PHP_SELF']
    John

  6. #6
    SitePoint Zealot poLka's Avatar
    Join Date
    Apr 2003
    Location
    GF
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe try $_SERVER['PHP_SELF']?

  7. #7
    SitePoint Member lstice's Avatar
    Join Date
    Mar 2003
    Location
    Cincinnati
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That works. Thanks!

  8. #8
    SitePoint Zealot poLka's Avatar
    Join Date
    Apr 2003
    Location
    GF
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your php.ini file had the default setting of auto_globals = off (just thought i'd throw that in) cheers!

  9. #9
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm puzzled as to how PHP was producing even part of the script's filename before without globals on. What's up with that?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  10. #10
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Were you doing any kind of modification to the $PHP_SELF variable before you were attempting to print it to the screen?
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.


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
  •