PHP SSI Problem- Please Help

Discussion in 'PHP' started by bubaipal, Nov 26, 2009.

  1. #1
    Hello PHP masters
    I am very new to php and have this problem. I have a little quiz made with php. It works fine but breaks whenever I enable ssi

    My earlier htacess
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^teenagelovetips\.com
    RewriteRule ^(.*)$ http://www.teenagelovetips.com/$1 [R=permanent,L]
    AddType text/html .shtml .html .htm 
    AddHandler server-parsed .shtml .html .htm 
    Options Indexes FollowSymLinks Includes 
    Code (markup):
    My new htaccess
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^teenagelovetips\.com
    RewriteRule ^(.*)$ http://www.teenagelovetips.com/$1 [R=permanent,L]
    AddType text/html .shtml .html .htm [B].php[/B]
    AddHandler server-parsed .shtml .html .htm [B].php[/B]
    Options Indexes FollowSymLinks Includes 
    Code (markup):
    I guess this is how to enable ssi pn .php pages.

    When I enable ssi this way, the ssi elements work but the php script breaks.

    Normal

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
     	
    	
    
    
    
    Are you ready to know if you are in Teenage love. Then answer the following questions.
    
    <form id="form1" name="form1" method="post" action="">
    1)Have you ever thought about kissing him?
      <label>
        <br />
        <input type="radio" name="RadioGroup1" value="1" id="RadioGroup1_0" />
    
      Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup1" value="0" id="RadioGroup1_1" />
        No</label>
      <br />
    
    
    2)Can you sacrifice anything for him?<br /><label>
    
        
        <input type="radio" name="RadioGroup2" value="1" id="RadioGroup2_0" />
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup2" value="0" id="RadioGroup2_1" />
        No</label>
      <br />
        
    
    3)Do you see any special quality in him that others don't notice?<br />
    <label>
            <input type="radio" name="RadioGroup3" value="1" id="RadioGroup3_0" />
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup3" value="0" id="RadioGroup3_1" />
        No</label>
    
      <br />
    
    4)Are you feeling less hungry of late?<br /><label>
            <input type="radio" name="RadioGroup4" value="1" id="RadioGroup4_0" />
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup4" value="0" id="RadioGroup4_1" />
        No</label>
    
      <br />
    
    
    5)Does he come in mind when you sleep in your dreams?<br /><label>
            <input type="radio" name="RadioGroup5" value="1" id="RadioGroup5_0" />
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup5" value="0" id="RadioGroup5_1" />
    
        No</label>
      <br />
    
    
    6)Do you feel jealous when they talk to others?<br /><label>
            <input type="radio" name="RadioGroup6" value="1" id="RadioGroup6_0" />
        Yes</label>
      <br />
      <label>
    
        <input type="radio" name="RadioGroup6" value="0" id="RadioGroup6_1" />
        No</label>
      <br />
    
    
    7)Do you feel good when he/she is with you?<br /><label>
            <input type="radio" name="RadioGroup7" value="1" id="RadioGroup7_0" />
        Yes</label>
      <br />
    
      <label>
        <input type="radio" name="RadioGroup7" value="0" id="RadioGroup7_1" />
        No</label>
      <br />
    
    
    8)Do you want to be with he/she alone?<br /><label>
            <input type="radio" name="RadioGroup8" value="1" id="RadioGroup8_0" />
        Yes</label>
    
      <br />
      <label>
        <input type="radio" name="RadioGroup8" value="0" id="RadioGroup8_1" />
        No</label>
      <br />
    
    
    9)Do you feel bad when someone interupts your conversation?<br /><label>
            <input type="radio" name="RadioGroup9" value="1" id="RadioGroup9_0" />
    
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup9" value="0" id="RadioGroup9_1" />
        No</label>
      <br />
    
    
    10)What were you thinking before reaching here for this test?<br /><label>
    
            <input type="radio" name="RadioGroup10" value="1" id="RadioGroup10_0" />
        Him/Her</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup10" value="0" id="RadioGroup10_1" />
        Something else<br />
      </label>
      <br /><label><input name="Am I in Love?" type="submit" value="Am I in Love?" /></label>
    
    
    </form>
    <table width="500" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><script type="text/javascript"><!--
    google_ad_client = "pub-3761176936177898";
    /* 468x60, created 10/1/09 */
    google_ad_slot = "7758836288";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></td>
              </tr>
        </table>
     
    
    
    
    </body>
    
    </html>
    Code (markup):
    Broken with ssi enabled

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <?php
    $One = $_POST["RadioGroup1"];
    $Two = $_POST["RadioGroup2"];
    $Three = $_POST["RadioGroup3"];
    $Four = $_POST["RadioGroup4"];
    $Five = $_POST["RadioGroup5"];
    $Six = $_POST["RadioGroup6"];
    $Seven = $_POST["RadioGroup7"];
    $Eight = $_POST["RadioGroup8"];
    $Nine = $_POST["RadioGroup9"];
    $Ten = $_POST["RadioGroup10"];
    $d = $One+$Two+$Three+$Four+$Five+$Six+$Seven+$Eight+$Nine+$Ten ;	
    if (isset($_REQUEST['RadioGroup1']))  {
    
    
    if ($d=="1")
      echo "<strong style=font-size: 16px>You are not in Love at all</strong>";
    elseif ($d=="2")
      echo "<strong style=font-size: 16px>Very little chance of Love</strong>";
    elseif ($d=="3")
      echo "<strong style=font-size: 16px>I can see a little bit of love peeping from inside you</strong>";
    elseif ($d=="4")
      echo "<strong style=font-size: 16px>I think you are getting into love</strong>";
    elseif ($d=="5")
      echo "<strong style=font-size: 16px>You do have some feelings for him</strong>";
    elseif ($d=="6")
      echo "<strong style=font-size: 16px>Yes, you have a soft corner for him</strong>";
    elseif ($d=="7")
      echo "<strong style=font-size: 16px>You surely have feelings and love for the person</strong>";
    elseif ($d=="8")
      echo "<strong style=font-size: 16px>You are definitely in love</strong>";
    elseif ($d=="9")
      echo "<strong style=font-size: 16px>You are floating in love</strong>";
    elseif ($d=="10")
      echo "<strong style=font-size: 16px>Why are you even taking this test? You know that you are in deep deep love, don't you?</strong>"; 	
    ?>
    
    <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>"
     <table width="500" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><script type="text/javascript"><!--
    google_ad_client = "pub-3761176936177898";
    /* 468x60, created 10/1/09 */
    google_ad_slot = "7758836288";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></td>
              </tr>
       <? echo "</table>Did you like our test? Was the result as you expected we hope so. As you know this site is totally dedicated to teengers and intended to help them on their love life. So if you need any help about love, flirting, eye contact, gift ideas, proposal ideas or anything else about teenage love, then feel free to check out the site. Thousands of teenagers visit this site every month and they are helped by this.Feel free to contact me through the appropiate page if have any questions. I will be very happy to help you out." 
       ?>
       <table width="500" border="0" cellspacing="0" cellpadding="0">
    
       
              <tr>
                <td><script type="text/javascript"><!--
    google_ad_client = "pub-3761176936177898";
    /* 468x60, created 10/1/09 */
    google_ad_slot = "4726486996";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </td>
              </tr>
            </table>"
    
    
    
    <?
    
    
    
    } else {
    	
    ?> 	
    	
    
    
    
    Are you ready to know if you are in Teenage love. Then answer the following questions.
    
    <form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF;?>">
    1)Have you ever thought about kissing him?
      <label>
    
        <br />
        <input type="radio" name="RadioGroup1" value="1" id="RadioGroup1_0" />
      Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup1" value="0" id="RadioGroup1_1" />
        No</label>
      <br />
    
    
    2)Can you sacrifice anything for him?<br /><label>
        
        <input type="radio" name="RadioGroup2" value="1" id="RadioGroup2_0" />
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup2" value="0" id="RadioGroup2_1" />
        No</label>
    
      <br />
        
    3)Do you see any special quality in him that others don't notice?<br />
    <label>
            <input type="radio" name="RadioGroup3" value="1" id="RadioGroup3_0" />
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup3" value="0" id="RadioGroup3_1" />
    
        No</label>
      <br />
    
    4)Are you feeling less hungry of late?<br /><label>
            <input type="radio" name="RadioGroup4" value="1" id="RadioGroup4_0" />
        Yes</label>
      <br />
      <label>
    
        <input type="radio" name="RadioGroup4" value="0" id="RadioGroup4_1" />
        No</label>
      <br />
    
    
    5)Does he come in mind when you sleep in your dreams?<br /><label>
            <input type="radio" name="RadioGroup5" value="1" id="RadioGroup5_0" />
        Yes</label>
      <br />
    
      <label>
        <input type="radio" name="RadioGroup5" value="0" id="RadioGroup5_1" />
        No</label>
      <br />
    
    
    6)Do you feel jealous when they talk to others?<br /><label>
            <input type="radio" name="RadioGroup6" value="1" id="RadioGroup6_0" />
        Yes</label>
    
      <br />
      <label>
        <input type="radio" name="RadioGroup6" value="0" id="RadioGroup6_1" />
        No</label>
      <br />
    
    
    7)Do you feel good when he/she is with you?<br /><label>
            <input type="radio" name="RadioGroup7" value="1" id="RadioGroup7_0" />
    
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup7" value="0" id="RadioGroup7_1" />
        No</label>
      <br />
    
    
    8)Do you want to be with he/she alone?<br /><label>
    
            <input type="radio" name="RadioGroup8" value="1" id="RadioGroup8_0" />
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup8" value="0" id="RadioGroup8_1" />
        No</label>
      <br />
    
    9)Do you feel bad when someone interupts your conversation?<br /><label>
            <input type="radio" name="RadioGroup9" value="1" id="RadioGroup9_0" />
        Yes</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup9" value="0" id="RadioGroup9_1" />
        No</label>
    
      <br />
    
    
    10)What were you thinking before reaching here for this test?<br /><label>
            <input type="radio" name="RadioGroup10" value="1" id="RadioGroup10_0" />
        Him/Her</label>
      <br />
      <label>
        <input type="radio" name="RadioGroup10" value="0" id="RadioGroup10_1" />
    
        Something else<br />
      </label>
      <br /><label><input name="Am I in Love?" type="submit" value="Am I in Love?" /></label>
    
    
    </form>
    <table width="500" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><script type="text/javascript"><!--
    google_ad_client = "pub-3761176936177898";
    /* 468x60, created 10/1/09 */
    google_ad_slot = "7758836288";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    
    </script></td>
              </tr>
        </table>
    <?
    }
    ?> 
    
    
    
    </body>
    </html>
    Code (markup):
    Any help is very much appreciated. You can look at the broken page here.
     
    bubaipal, Nov 26, 2009 IP
  2. bubaipal

    bubaipal Peon

    Messages:
    939
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    No one can help? [BUMO]
     
    bubaipal, Nov 27, 2009 IP
  3. kbduvall

    kbduvall Peon

    Messages:
    71
    Likes Received:
    3
    Best Answers:
    4
    Trophy Points:
    0
    #3
    When you put:
    
    AddHandler server-parsed .shtml .html .htm .php
    
    Code (markup):
    You're telling the server to stop using PHP to parse .php files and instead use the server to parse it.

    I don't see anything special in your second PHP file. Why are you trying to use SSI?
     
    kbduvall, Nov 27, 2009 IP
  4. bubaipal

    bubaipal Peon

    Messages:
    939
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I need to use SSI to include menus, footer and ads. Is there a way to use ssi with the script working properly. The second PHP file is nothing special, just the whole php file. In the 1st one, the second file is properly processed, thats it.

    Can you help me to get the php and ssi working simultaneously? If the server is processing the file why can't it process the php part (sorry, i a m new to php and stuff):)
     
    bubaipal, Nov 28, 2009 IP
  5. kbduvall

    kbduvall Peon

    Messages:
    71
    Likes Received:
    3
    Best Answers:
    4
    Trophy Points:
    0
    #5
    I believe you don't need to turn it on in your .htaccess and can instead, call it from within PHP using virtual() to include your SSI files and include()/require() to include your PHP files.

    It's generally not a good idea to have SSI turned on for every page (IE: pages that don't use SSI) because Apache will parse every single page even if it's not needed. That can cause considerable performance issues.

    The best way to mix the two would be to set the handlers back to normal (php for .php files and .html parsed normally) and use the PHP function virtual() to include your SSI files.
     
    kbduvall, Nov 28, 2009 IP
    bubaipal likes this.
  6. bubaipal

    bubaipal Peon

    Messages:
    939
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks, I will call the SSI files using php include on php pages.:)
     
    bubaipal, Nov 28, 2009 IP