Results 1 to 6 of 6

Thread: [RESOLVED] help

  1. #1

    Thread Starter
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Resolved [RESOLVED] help

    i dont no wats wrong with these code samples...
    Code:
    	session_name ('User');
    	session_start();
    	$_SESSION['username'] = 'testing';
    	$_SESSION['loggedin'] = time();
    		header ('Location: http://$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/welcome.php');
    		exit ();
    		} else {
    		echo '<p>The submittes username and password do not match those on file.<br />
    		     Go back and try again.</p>';
    and

    Code:
    <?php
    
    session_start();
    require ('header.php');
    
    echo '<h3>Welcome to Distorted View, ' . ucfirst($_SESSION['username']) . '!</h3>;
    echo '<p>You have been logged in since:<br /> ' . date ('g:i a', $_SESSION['loggedin']) . '</p>';
    
    echo '<p><a href="logout.php" title="Log Out">Log Out</a></p>';
    
    require ('footer.php');
    
    ?>
    they both contain parse errors ( an unexpected T_STRING error in the first where the header (line 15ish)i s and an unexpected '>' in the second one (line 7ish))

  2. #2
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: help

    Been a while since I did any PHP

    Your problem seems to be where you are referencing your arrays while 'inside' a string.

    You have the line

    'Location: http://$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/welcome.php'

    Which really needs to be

    'Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/welcome.php'

    This is because the ' character begins and ends your string. Hence your problem

    The problem with your second example is quote marks.

    echo '<p><a href="logout.php" title="Log Out">Log Out</a></p>';

    Might I recommend you use a syntax hightligher for PHP. This will make it clear where you begin and end a string, and highlight syntax errors.

    Good Luck!

  3. #3

    Thread Starter
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: help

    it says the problem is on line 7 for the second one... this is line 7

    echo '<p>You have been logged in since:<br /> ' . date ('g:i a', $_SESSION['loggedin']) . '</p>';

    the first one worx now thanx but the second is still weird

  4. #4
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: help

    Ah look here is the problem :0

    echo '<h3>Welcome to Distorted View, ' . ucfirst($_SESSION['username']) . '!</h3>;

    You do not terminate the string after </H3>;

    A syntax highlighter would have shown this problem !!

  5. #5

    Thread Starter
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: help

    so wat should it be? sry im new

  6. #6

    Thread Starter
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: help

    n/m i got it

    thanx Duck

Posting Permissions

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



Click Here to Expand Forum to Full Width