Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
The simplest of problems is driving me insane!
Old 06-03-2009, 03:33 PM The simplest of problems is driving me insane!
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
I have one bit of code in a file:
PHP Code:
<?php
session_start 
();
require 
'../authAdmin.php';
?>
and this is in authAdmin.php:
PHP Code:
<?php

// restrict certain pages with this script
// forward user to login page if not logged in

if ($_SESSION['userId'] != 1) {
    
header ('Location: ' $_SERVER['DOCUMENT_ROOT'];
    exit;
}

?>
But instead of forwarding to the root directory, I keep getting this very unhelpful error message:

Quote:
Parse error: parse error in C:\xampp\htdocs\xampp\penguinpages.co.uk\script\ph p\authAdmin.php on line 7
Ive been trying for about half an hour to fix it and am getting nowhere. Ive even tried replacing the $_SERVER variable with the actual path. If I echo the $_SERVER variable it appears correct!?
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
 
Register now for full access!
Old 06-03-2009, 03:35 PM Re: The simplest of problems is driving me insane!
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
It looks like you forgot to close your parens on your call to header:
PHP Code:
header('Location: ' $_SERVER['DOCUMENT_ROOT']); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 06-03-2009, 03:40 PM Re: The simplest of problems is driving me insane!
Corey's Avatar
Super Talker

Latest Blog Post:
Pre-Pop Offers
Posts: 142
Name: Corey
Location: United States
Trades: 0
Nevermind .
__________________

Please login or register to view this content. Registration is FREE

Phone: 888-400-4359 || AIM S/N: CoreyPeerFly
Launched in 2008 - Daily Payments by PayPal
Corey is offline
Reply With Quote
View Public Profile Visit Corey's homepage!
 
Old 06-03-2009, 03:44 PM Re: The simplest of problems is driving me insane!
pealo86's Avatar
Super Spam Talker

Posts: 876
Name: Matt Pealing
Location: England, north west
Trades: 0
Quote:
Originally Posted by NullPointer View Post
It looks like you forgot to close your parens on your call to header:
PHP Code:
header('Location: ' $_SERVER['DOCUMENT_ROOT']); 
Genius! Thanks, but unfortunately, this brings me back to the problem I had before. No error is generated... but the page just doesn't do anything at all! Hmmmm. Could it be anything to do with me testing the server locally using XAMPP?
__________________

Please login or register to view this content. Registration is FREE
pealo86 is offline
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 06-04-2009, 03:15 AM Re: The simplest of problems is driving me insane!
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
It might be your generating output before the header redirect http://uk.php.net/manual/en/function.header.php. This would generate 'headers already sent' error if you have full error reporting.

Try this at the top of the script
PHP Code:
ini_set('error_reporting'E_ALL);
ini_set('display_errors'1
Also you need to redirect to a specific page
PHP Code:
header ('Location: index.php'); 
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to The simplest of problems is driving me insane!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.51806 seconds with 12 queries