Announcement

Collapse
No announcement yet.

Script help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script help

    I'm trying to run the following php code.

    PHP Code:
    <?php 

    switch($nav

    case 
    "about"
    include ("about.txt");
    break;

    case 
    "forums"
    include ("forums.txt");
    break;

    case 
    "contact"
    include ("contact.php");
    break;

    case 
    "staff"
    include ("staff.txt");
    break;

    case 
    "links"
    include ("links.txt");
    break;

    case 
    "downloads"
    include (
    "downloads.txt"); 
    break; 

    case 
    "projects":
    include (
    "projects.txt");
    break;

    default: 
    include (
    "news.txt"); 


    ?>

    But I keep getting this error whenever I excute it
    Parse error: parse error, unexpected T_INCLUDE in /home/surrix/public_html/test.php on line 41

    The code is supposed to be switching out the content that appares in one of the tables when a link is click on and the links would look something like this www.surrix.net/index.php?nav=forums or whatever but I can't get it to work what is wrong with it?
    Surrix.net: Computer help forums/articles

    The person in my avatar is Elisha Cuthbert she plays on Fox's 24

  • #2
    Very odd, since there are only 37 lines of code.
    You're my Prince of Peace
    And I will live my life for You

    Comment


    • #3
      Oh I just posted the script I didn't post the html parts of the page. The line that it is complaining about is the frist Include() like
      Surrix.net: Computer help forums/articles

      The person in my avatar is Elisha Cuthbert she plays on Fox's 24

      Comment


      • #4
        It looks like you are missing some colons here:
        PHP Code:
        case "about"
        include ("about.txt");
        break;

        case 
        "forums"
        include ("forums.txt");
        break;

        case 
        "contact"
        include ("contact.php");
        break;

        case 
        "staff"
        include ("staff.txt");
        break;

        case 
        "links"
        include ("links.txt");
        break; 

        Comment


        • #5
          I don't think I'm missing anything btw the thing in that box is the same as my code above.
          Surrix.net: Computer help forums/articles

          The person in my avatar is Elisha Cuthbert she plays on Fox's 24

          Comment


          • #6
            Paste line 41 here then
            You're my Prince of Peace
            And I will live my life for You

            Comment


            • #7
              PHP Code:
              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

              <html>
              <head>
                <title>Surrix - Come and see what we are doing...Then tell us because we don't know</title>
                <link rel="STYLESHEET" type="text/css" href="style.css">
              </head>
              <body bgcolor="#ADC6E7" link="black" vlink="black" alink="black">

                <table width="100%" height="100%" cellpadding="0" cellspacing="0" class="main">
                <tr height="10">
                  <td width="208" valign="top">
                    <center><img src="images/logo.gif" alt="" border="0"></center>
                    


                    
                    <p align="right">
                      .: <a href="index.php">home</a> .:<br>
                      .: <a href="index.php?nav=projects">projects</a> .:<br>
                      .: <a href="index.php?nav=downloads">downloads</a> .:<br>
                      .: <a href="index.php?page=forums">forums</a> .:<br>
                      .: <a href="index.php?page=about">about</a> .:<br>
                      .: <a href="index.php?page=contact">contact</a> .:<br>
                      .: <a href="index.php?nav=staff">staff</a> .: <br>
                      .: <a href="index.php?nav=links">links</a> .: <br>
                    </p>
                    
                  </td>
                  <td width="16"></td>
                  <td bgcolor="Black" width="1"></td>
                  <td bgcolor="#EFF7F7" width="16"></td>
                  <td bgcolor="#EFF7F7" valign="top">
                    <br><br><br><br>
                    
              <?php 

              switch($nav

              case 
              "about"
              include ("about.txt");
              break;

              case 
              "forums"
              include ("forums.txt");
              break;

              case 
              "contact"
              include ("contact.php");
              break;

              case 
              "staff"
              include ("staff.txt");
              break;

              case 
              "links"
              include ("links.txt");
              break;

              case 
              "downloads"
              include (
              "downloads.txt"); 
              break; 

              case 
              "projects":
              include (
              "projects.txt");
              break;

              default: 
              include (
              "news.txt"); 


              ?> 
                    
                  </td>
                  <td bgcolor="#EFF7F7" width="16"></td>
                  <td bgcolor="Black" width="1"></td>
                  <td width="16"></td>
                </tr>
                </table>

              </body>
              </html>
              That is the whole index.php line 41 is
              PHP Code:
              include ("about.txt"); 
              Surrix.net: Computer help forums/articles

              The person in my avatar is Elisha Cuthbert she plays on Fox's 24

              Comment


              • #8
                Originally posted by SquareFiles
                I don't think I'm missing anything btw the thing in that box is the same as my code above.
                I know, that was the point. Isn't it supposed to be like
                PHP Code:
                case 'asdf':
                do_something();
                break; 
                ?

                Comment


                • #9
                  @MUG is right
                  try this
                  PHP Code:
                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

                  <html>
                  <head>
                    <title>Surrix - Come and see what we are doing...Then tell us because we don't know</title>
                    <link rel="STYLESHEET" type="text/css" href="style.css">
                  </head>
                  <body bgcolor="#ADC6E7" link="black" vlink="black" alink="black">

                    <table width="100%" height="100%" cellpadding="0" cellspacing="0" class="main">
                    <tr height="10">
                      <td width="208" valign="top">
                        <center><img src="images/logo.gif" alt="" border="0"></center>
                        


                        
                        <p align="right">
                          .: <a href="index.php">home</a> .:<br>
                          .: <a href="index.php?nav=projects">projects</a> .:<br>
                          .: <a href="index.php?nav=downloads">downloads</a> .:<br>
                          .: <a href="index.php?page=forums">forums</a> .:<br>
                          .: <a href="index.php?page=about">about</a> .:<br>
                          .: <a href="index.php?page=contact">contact</a> .:<br>
                          .: <a href="index.php?nav=staff">staff</a> .: <br>
                          .: <a href="index.php?nav=links">links</a> .: <br>
                        </p>
                        
                      </td>
                      <td width="16"></td>
                      <td bgcolor="Black" width="1"></td>
                      <td bgcolor="#EFF7F7" width="16"></td>
                      <td bgcolor="#EFF7F7" valign="top">
                        <br><br><br><br>
                        
                  <?php 

                  switch($nav

                  case 
                  "about";
                  include (
                  "about.txt");
                  break;

                  case 
                  "forums";
                  include (
                  "forums.txt");
                  break;

                  case 
                  "contact";
                  include (
                  "contact.php");
                  break;

                  case 
                  "staff";
                  include (
                  "staff.txt");
                  break;

                  case 
                  "links";
                  include (
                  "links.txt");
                  break;

                  case 
                  "downloads";
                  include (
                  "downloads.txt"); 
                  break; 

                  case 
                  "projects";
                  include (
                  "projects.txt");
                  break;

                  default;
                  include (
                  "news.txt"); 


                  ?> 
                        
                      </td>
                      <td bgcolor="#EFF7F7" width="16"></td>
                      <td bgcolor="Black" width="1"></td>
                      <td width="16"></td>
                    </tr>
                    </table>

                  </body>
                  </html>
                  You're my Prince of Peace
                  And I will live my life for You

                  Comment


                  • #10
                    god where do u ppl learn to program ????


                    <?php

                    switch($nav)
                    {
                    case "about":
                    include ("about.txt");
                    break;

                    case "forums":
                    include ("forums.txt");
                    break;

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

                    case "staff":
                    include ("staff.txt");
                    break;

                    case "links":
                    include ("links.txt");
                    break;

                    case "downloads":
                    include ("downloads.txt");
                    break;

                    case "projects":
                    include ("projects.txt");
                    break;

                    default:
                    include ("news.txt");
                    }

                    ?>

                    Comment


                    • #11
                      I don't know.. It's in the docs..
                      http://www.php.net/manual/en/control...res.switch.php

                      Comment


                      • #12
                        and u shud always use single quotes, as they rnt parsed and increase speed

                        you dont need any quotes in the switch function, but its good practice to use them.

                        Comment


                        • #13
                          @megahard god where did u learn to spell

                          I think you guys are right with the colon thing and I'm sorry for saying your were wrong MUG I guess I didn't get what you were talking about I will tell you guys what I come up with.
                          Surrix.net: Computer help forums/articles

                          The person in my avatar is Elisha Cuthbert she plays on Fox's 24

                          Comment


                          • #14
                            megahard god where did u learn to spell
                            irc

                            Comment


                            • #15
                              LoL Well I got the colon thing to work it changes just how I want it to too so we are all good thanks guys.
                              Surrix.net: Computer help forums/articles

                              The person in my avatar is Elisha Cuthbert she plays on Fox's 24

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X