1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP related question

Discussion in 'HTML & Website Design' started by NewComputer, Aug 1, 2004.

  1. #1
    I have a .php inlcude that is blowing out my template from left to right. Below is a sample of the code.

    <td width="71%" height="444" valign="top"><table width="100%" height="2%" border="0" align="center" cellpadding="0" cellspacing="0" class="text">
                <tr>
                  <td colspan="10"><div align="left"><font color="#000000"><b>
    			    <? include 'mysecret.php'; ?>
    			    <? include 'also_my_secret.php'; ?>
                  </b></font></div></td>
                </tr>
                <tr>
                  <td height="14"><div align="justify"></div></td>
                </tr>
    Code (markup):
    Here is the code that is blowing out the template
    SEMrush
    <?
    $URL = "http://www.myotherwebsite.com/testing.html";
    $FILE = fopen("$URL", "r");
    $r = "";
    do {
       $DATA = fread($FILE, 8192);
       if (strlen($DATA) == 0) {
           break;
       }
       $r .= $DATA;
    } while (true);
    $START = '<TD bgcolor="#F7F7EC" colspan="10"align="center"><b>Closed Term</b></td>';
    $END = '<br>Random info<br>';
    $STUFF = eregi("$START(.*)$END", $r, $CONTENT); 
    $REP1 = eregi_replace("\r", "", $CONTENT[1]);
    $REP2 = eregi_replace(' bgcolor="#CCCC99"', "", $REP1);
    $REP3 = eregi_replace('<TD class="bodytext" bgcolor="#F7F7EC" colspan="10" align="center">', '</TABLE>', $REP2);
    $REP4 = eregi_replace(' bgcolor="#F7F7EC"', "", $REP3);
    $REP5 = eregi_replace(' BGCOLOR="CCCC99"', "", $REP4);
    $REP6 = eregi_replace("\n\n", "", $REP5);
    $REP7 = eregi_replace(' bgcolor="F7F7EC"', "", $REP6);
    fclose($FILE);
    echo $REP7;
    
    //$OUT = fopen("index.html", "w");
    //fwrite($OUT, $REP6);
    //fclose($OUT);
    
    ?>
    PHP:
    Any ideas. In the old template is displayed fine.
     
    NewComputer, Aug 1, 2004 IP
    SEMrush
  2. xml

    xml Peon

    Messages:
    254
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I suggest using arrays for your replacement values, also use str_replace on basic replacement, its much faster.
     
    xml, Aug 2, 2004 IP
  3. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    To prevent any confusion it is better to use " <?php " for opening tags, and yes " <? " should work but a change in the server configuration could break your scripts.
     
    mushroom, Aug 2, 2004 IP
  4. Googl2

    Googl2 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I suggest using Smarty at "smarty.php.net". It's not what you want to hear, but it is the best PHP/Template system out there.
     
    Googl2, Aug 4, 2004 IP