Php Problem

Discussion in 'Gaming' started by Phili G, Aug 2, 2007.

  1. Phili G

    Phili G Well-Known Member

    Age:
    33
    Posts:
    1,498
    Likes Received:
    0
    Joined:
    Oct 5, 2005
    Location:
    England!
    Ive wrote a script that deals with the editing and deleting of articles in a database.

    To do this I have used nested ifs and a elseif

    Code:
    if {
        //codehere
     if {
         //codehere
     }
    }
    elseif {
     //codehere
    } 
    else {
        //codehere
    }
    
    with that I would get a error saying
    Code:
    Parse error: syntax error, unexpected '}' in "path" on line 9
    I have no idea whats wrong with the code, can some body help me?
     
  2. -=DaRKSTaR=-

    -=DaRKSTaR=- Senior Member

    Age:
    36
    Posts:
    3,949
    Likes Received:
    0
    Joined:
    Mar 30, 2005
    Location:
    England, UK
    hm .. the { / } are all closed hm .. try deleting the } on line 9 see what happens
     
  3. Phili G

    Phili G Well-Known Member

    Age:
    33
    Posts:
    1,498
    Likes Received:
    0
    Joined:
    Oct 5, 2005
    Location:
    England!
    I get unexpected T_ELSE. If i remove the else { it will come up with unexpected T_STRING
    (im using ob_start() and ob_flush() so I can modify the header and redirect the page once one of the ifs have been completed)
     
  4. Littlej

    Littlej Well-Known Member

    Posts:
    1,971
    Likes Received:
    0
    Joined:
    Aug 13, 2006
    Giving that a quick lookover I don't think there is anything wrong with it, somthing else in your code may be causing it, for example missing a ; at the end of the statement can cause an unexpected $ error. If you could post a little more of the code it might help (though I'd assume you wouldn't want to post it) or perhaps just blank out things if you don't want people to steal the script :)

    Oh and just a guess, maybe go through and check that every statement is actually ended with a ; the majority of the time I get errors it's usually because I've missed one somewhere.
     
  5. Phili G

    Phili G Well-Known Member

    Age:
    33
    Posts:
    1,498
    Likes Received:
    0
    Joined:
    Oct 5, 2005
    Location:
    England!
    gives
    Code:
    Parse error: syntax error, unexpected '}' on line 47
    (which is after the elseif statement)


    I know it isnt very secure, but Im just creating a base edit/delete script
     
  6. Littlej

    Littlej Well-Known Member

    Posts:
    1,971
    Likes Received:
    0
    Joined:
    Aug 13, 2006
    elseif (isset($id)&&($delete)) {
    mysql_query("DELETE FROM articles WHERE id=$id");
    }

    Pretty sure that's your problem ( it was missing: ; ), post back if it dosn't work still though :) (just looked quickly)
     
  7. Phili G

    Phili G Well-Known Member

    Age:
    33
    Posts:
    1,498
    Likes Received:
    0
    Joined:
    Oct 5, 2005
    Location:
    England!
    you got it, thank you!
     

Share This Page