#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    3
    Rep Power
    0
    Hi there trying to get into the php grove, but having some issues. This little script worked in php4 but on another server running php3 it won't work. My best guess was to include the variables first but this did not work. I get a parse error on the first else if. Thanks for any help in advance ;-)

    if ( !$pbdmain | | $pbdmain == "" )
    $pbdmain = "home";
    if ( $pbdmain == "home" )
    include ( "home.inc" );
    elseif ( $pbdmain == "profile" )
    include ( "profile.inc" );
    elseif ( $pbdmain == "services" )
    include ( "services.inc" );
    elseif ( $pbdmain == "clients" )
    include ( "clients.inc" );
    elseif ( $pbdmain == "contact" )
    include ( "contact.inc" );
    elseif ( $pbdmain == "sitemap" )
    include ( "sitemap.inc" );
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    19
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    if ( !$pbdmain | | $pbdmain == "" )
    $pbdmain = "home";
    [/quote]

    Do you volontarly have a space between | and |? You have one. I think the right thing to do would be to write your conditional statement without spaces between the two |.

    Hope this helps.

    Bakassi


    [This message has been edited by bakassi (edited September 19, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    3
    Rep Power
    0
    Hey thanks, now it sort of works *lol* piece by piece... ;-)
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    19
    Rep Power
    0
    No problem, Let me know if you need any kind of help .

    [This message has been edited by bakassi (edited September 19, 2000).]
  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    Glad it works now but I think you will find that the forum itself puts a space between double pipes - testing it here | |

    ....

    yep - its a UBB thing - not sure why it does it, as for the code - I do not know if it makes much difference - but I would lose the space between the '(' and the statement - & use braces, ie:

    if(!$thiscond &#0124; &#0124; !$thatcond){ /*do this*/ }

    etc.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL

    [This message has been edited by firepages (edited September 19, 2000).]
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    3
    Rep Power
    0
    Thanks firepages I got it working now, it turns out that the reason it seemed to work was because the last 'elseif' was functional but the ones prior were not. But if you change the 'elseif' statments to 'if' statments php3 loves you!! And the problem solved. Thanks again firepages and bakassi...
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    16
    Heh, UBBs stores all the data in flat-files and uses &#0124; &#0124; as the delimiter. If you know perl, you'd know what I'm talking about.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    16
    Oh, and as far as you problems... you needed to either have endif; or an esle{} so php knows when to end the if-ing.
  16. #9
  17. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Colchester, England
    Posts
    131
    Rep Power
    15
    Here is a completely alternative solution. The following compares $pbdmain with a list of cases, when it matches, the code following the case statement is executed. Break causes execution to break from the switch code so no more compares are done. If $pbdmain doesn’t match any of the cases the "default" code is run.


    switch ($pbdmain) {

    case "profile":
    include ( "profile.inc" );
    break;

    case "services":
    include ( "services.inc" );
    break;

    case "clients":
    include ( "clients.inc" );
    break;

    case "contact" :
    include ( "contact.inc" );
    break;

    case "sitemap":
    include ( "sitemap" );
    break;

    default:
    include ( "home.inc" );
    break;

    }

    Andy J

Similar Threads

  1. the linker, the include and interdependent classes
    By behco in forum C Programming
    Replies: 7
    Last Post: February 1st, 2004, 07:55 AM
  2. the linker, the include and interdependent classes
    By behco in forum C Programming
    Replies: 0
    Last Post: January 31st, 2004, 12:57 PM
  3. for() and children issues
    By SynAck in forum C Programming
    Replies: 3
    Last Post: December 11th, 2003, 03:46 AM
  4. include path problems - after uploading to host
    By alaw in forum PHP Development
    Replies: 2
    Last Post: December 9th, 2003, 05:11 PM
  5. Replies: 6
    Last Post: October 3rd, 2003, 01:01 PM

IMN logo majestic logo threadwatch logo seochat tools logo