Results 1 to 4 of 4

Thread: [RESOLVED] ARGH!!! Braces and Includes

  1. #1

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Resolved [RESOLVED] ARGH!!! Braces and Includes

    Okay well here goes.

    On the header.php I've got an if statement that checks if a string is valid. If the string is valid it will print so this:

    PHP Code:
    if($string == 1) { 
    is at the end of header.php.

    On index.php it will include the header and then do what it can do:

    PHP Code:
    include("header.php") ;
    // Do the stuff
    include("footer.php") ; 
    And at the end it will do the footer, which closes the braces:

    PHP Code:
     

    Aaaanyway, on including running "index.php" I get a parse error, unexpected $END on header.php. This seems to be saying that it hasn't included all of the files before parsing... do i have to use another method, such as
    PHP Code:
    require("header.php"); 
    ???

    Regards,
    Rudi



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: ARGH!!! Braces and Includes

    Although the documentation does not say so, a little knowledge of how language parsers work suggests that each file must be syntactically complete, i.e. you cannot open any sort of construct in one file and close it in another.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: ARGH!!! Braces and Includes

    But you can open it before you include it and close it after:
    PHP Code:
    if ($string==1) { // open
        
    include('header.php');
    // close 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Hyperactive Member ..:RUDI:..'s Avatar
    Join Date
    Aug 2005
    Location
    Yorkshire, England! c0d: Da Vinci
    Posts
    344

    Re: ARGH!!! Braces and Includes

    Quote Originally Posted by visualAd
    But you can open it before you include it and close it after:
    PHP Code:
    if ($string==1) { // open
        
    include('header.php');
    // close 
    Yeah but the thing is... the header needs to be on every page to autenticate the string, it's a sortof member area.

    I guess I'll just have to have in the header:
    PHP Code:
    if($string == "1") {
    $auth['isadmin'] = "1";

    and then on each page:
    PHP Code:
    if(isset($auth['isadmin'])) {
    // do stuff

    either that or would this have the same effect, in header.php:
    PHP Code:
    if($string != 1) {
    die(
    "You aint an admin! Stop buzzin' round 'ere!");

    Because I guess that would virtually lock it, do you think that would have the same effect??

    Rudi



    My Personal Home | MageBB Home | Elders Online
    Yes, Noteme is my father.

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