I need help with PHP!!!

Lord Kokkei

Whooplaz!!!
  • 310
    Posts
    19
    Years
    ok so i found this code in this thread:https://www.pokecommunity.com/threads/29287
    then i insertrd it in the following way:
    PHP:
    echo "            <tr>\n";
    echo "              <td width=\"100%\" bgcolor=\"#808080\">\n";
    echo "<?php\n";
    echo "\n";
    echo "$news = \"news.php\";\n";
    echo "$error = \"404.htm\";\n";
    echo "$ext = \".htm\";\n";
    echo "\n";
    echo "if(!isset($_GET['id'])){\n";
    echo "include $news;\n";
    echo "}\n";
    echo "elseif($_GET['id'] == \"main\") {\n";
    echo "include $news;\n";
    echo "}\n";
    echo "elseif(isset($_GET['id']) && file_exists($_GET['id'].$ext)){\n";
    echo "include $_GET['id'].$ext;\n";
    echo "}\n";
    echo "else{\n";
    echo "include $error;\n";
    echo "}\n";
    echo "\n";
    echo "?>\n";
    echo "              </td>\n";
    echo "            </tr>\n";

    but when i went to my site this shows up:
    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /usr/export/www/hosting/sdz4/index.php on line 195

    so im wondering here if i insertrd the code wrong or something?
     
    Last edited:
    Okay, charlizard - forgive me if I sound harsh but:

    YOU DO NOT PUT PHP INTO echo() REQUESTS, UNLESS YOU KNOW WHAT YOU ARE DOING!!!!


    First off, is the <?php and the ?> before and after the code respectively?
    Second, here is how you should paste it in, if the second is correct:

    PHP:
    echo "			<tr>\n"; 
    echo "			 <td width=\"100%\" bgcolor=\"#808080\">\n"; 
    $news = "news.php";
    $error = "404.htm";
    $ext = ".htm";
    if(!isset($_GET['id'])){
    	 include $news;
    } elseif($_GET['id'] == "main") {
    	 include $news;
    } elseif(isset($_GET['id']) && file_exists($_GET['id'].$ext)){ 
       include $_GET['id'].$ext;
    } else {
    	 include $error;
    }
    echo "			  </td>\n"; 
    echo "			</tr>\n";
    Third, are all your files you want to include, in .htm format? If they aren't, change the $ext variable.

    That's enough help for now, IMHO.
     
    Back
    Top