Closed Thread
Results 1 to 8 of 8

Thread: Simple PHP error, wtf?

  1. #1
    Brandon's Avatar
    Brandon is offline Former Senior Account Rep Brandon is on a distinguished road
    Join Date
    Jun 2006
    Location
    Tewksbury, MA
    Posts
    9,589

    Simple PHP error, wtf?

    PHP Code:
    if (!file_exists('config.php')) {
     
    header("Location: install/install.php");

    it aint working and config.php isnt there, i am using apache 2.2.4 and php 5.2.1

    SIMPLEST thing ever and it isnt working, wtf...
    Thanks,
    Brandon Long

  2. #2
    Cubeform is offline x10 Lieutenant Cubeform is an unknown quantity at this point
    Join Date
    Aug 2006
    Location
    127.0.0.1
    Posts
    339

    Re: Simple PHP error, wtf?

    PHP header() redirects won't work with relative URLs; they will only work with the whole thing (i.e. with the "http://yourwebsite.com/"). Here's how you would do this:
    PHP Code:
    <?php
    $host  
    $_SERVER['HTTP_HOST'];
    $uri  rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    header("Location: http://$host$uri/install/install.php");
    exit;
    ?>
    (I got this from a PHP manual page and modified it slightly)
    Last edited by Cubeform; 02-10-2007 at 05:08 PM.
    CUBEFORM
    XHTML | CSS | PHP | JavaScript
    THIS WEEK


  3. #3
    Brandon's Avatar
    Brandon is offline Former Senior Account Rep Brandon is on a distinguished road
    Join Date
    Jun 2006
    Location
    Tewksbury, MA
    Posts
    9,589

    Re: Simple PHP error, wtf?

    Quote Originally Posted by Cubeform View Post
    PHP header() redirects won't work with relative URLs; they will only work with the whole thing (i.e. with the "http://yourwebsite.com/"). Here's how you would do this:
    PHP Code:
    <?php
    $host  
    $_SERVER['HTTP_HOST'];
    $uri  rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    header("Location: http://$host$uri/install/install.php");
    exit;
    ?>
    (I got this from a PHP manual page and modified it slightly)
    They do for me, and anything I try dosnt wirk, echo, die, i have tried it all:eek4:

    It isnt the header, thats all i know.
    Thanks,
    Brandon Long

  4. #4
    dharmil's Avatar
    dharmil is offline x10 Elder dharmil is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Avenel New Jersey
    Posts
    828

    Re: Simple PHP error, wtf?

    you could try

    PHP Code:
    <?php
    function goToUrl($ref$url){
        if (
    $url == ''){
            
    $url 'index.php';
        }
        
    header "refresh: $ref; url=".str_replace('&amp;''&'$url) ) ;
    }
    ?>
    i made it to redirect and it works fine

    or try:
    PHP Code:
    <?php
    header
    ('Location: '.str_replace('&amp;''&''http://www.example.com/?do=1&go'));
    ?>
    Last edited by dharmil; 02-10-2007 at 05:55 PM.

  5. #5
    Brandon's Avatar
    Brandon is offline Former Senior Account Rep Brandon is on a distinguished road
    Join Date
    Jun 2006
    Location
    Tewksbury, MA
    Posts
    9,589

    Re: Simple PHP error, wtf?

    The redirect is fine

    its that file_exists thing
    Thanks,
    Brandon Long

  6. #6
    dharmil's Avatar
    dharmil is offline x10 Elder dharmil is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Avenel New Jersey
    Posts
    828

    Re: Simple PHP error, wtf?

    try
    file_exists('/config.php')

  7. #7
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Simple PHP error, wtf?

    Do you get an error at all, or does it just not return true/false like it "should?"

  8. #8
    Brandon's Avatar
    Brandon is offline Former Senior Account Rep Brandon is on a distinguished road
    Join Date
    Jun 2006
    Location
    Tewksbury, MA
    Posts
    9,589

    Re: Simple PHP error, wtf?

    ****, thats the problem, i was editing a read-only file and it wasnt saving, it works now:-P
    Last edited by Brandon; 02-10-2007 at 07:43 PM.
    Thanks,
    Brandon Long

Closed Thread

Similar Threads

  1. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  2. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  3. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  4. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  5. A noobish simple PHP ?
    By AllStarGamer101 in forum Graphics & Webdesign
    Replies: 4
    Last Post: 12-20-2005, 06:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers