Results 1 to 2 of 2

Thread: parse error on switch

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2007
    Location
    cobwebbed to PC
    Posts
    311

    parse error on switch

    Hi All

    received
    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/www/tobmol0.freehostia.com/indexa.php on line 44
    for
    Code:
    <?php
    							    switch($_GET[id])
    								{
    									case "cv":
    										$title "CV"; //this is line 44.
    										$main_content = "cv";
    										break;
    									case "library":
    										$title = "Lib";
    										$include = "lib.php";
    										break;
    									case "papps:":
    										$title = "PApps";
    										$include = "papps.php";
    										break;
    									case "art":
    										$title = "Art";
    										$include = "art.php";
    										break;
    									case "thesis":
    										$title = "Thesis";
    										$include = "thesis.php";
    										break;
    									case else:
    										$title = "CV";
    										$include = "cv.php";
    								}
    							?>
    this is followed by
    Code:
    <?php echo $title; ?>
    <?php include($main_content); ?>
    then url of form
    Code:
    index.php?id=cv
    thanks for any help only a noob to php so prob some thing very basic
    Thanks

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: parse error on switch

    You're missing the equal sign.

    $title "CV";

    should be

    $title = "CV";

    The error you posted basically says that it found an "Encapsed_String" where there shouldn't be one. Aka your line should either end after $title, or you needed to add the assignment operator.

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