Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-22-2006, 01:59 PM Echoing PHP code
Average Talker

Posts: 15
Trades: 0
I'm having trouble echoing an HTML page containing PHP

I'm trying to make it so it'll echo this HTML page, the HTML page also contains abit of PHP, it echos out the HTML fine, but it doesn't seems to be echoing it out as an HTML page, so you see all the php code as text.

here's where it starts to echo the code.

PHP Code:
}else{die('
<html>
<head>
<title>Destroi.com</title>
<style type="text/css">
<!--
.style1 {color: #5c7889}
.style2 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {
 color: #5c7889;
 font-family: Verdana, Arial, Helvetica, sans-serif;
 font-size: x-small;
}
.style4 {font-size: xx-small}
.style5 {font-size: x-small}
.style7 {
 color: #B5CFD5;
 font-size: 10px;
 font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style10 {color: #B5CFD5}
-->
</style>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body bgcolor="#B5CFD5" text="#FFFFFF" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<table width="651" border="0" cellpadding="0" cellspacing="0" align="center">
  <!--DWLayoutTable-->
  <tr> 
    <td height="128" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="http://www.destroi.com/images/addapta/banner_w650_h168.jpg">
      <!--DWLayoutTable-->
      <tr>
        <td width="28" height="24">&nbsp;</td>
          <td width="120">&nbsp;</td>
          <td width="502">&nbsp;</td>
        </tr>
      <tr>
        <td height="92">&nbsp;</td>
          <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <!--DWLayoutTable-->
              <tr>
                <td width="120" height="40" valign="top"><form name="form1" method="post" action="">
                  <label><span class="style7">Username
                    </span>
                    <input name="username" type="text" id="username" value="<?PHP
 
echo "\"$username2\"";
 if (
$username2 != ""){echo "DISABLED";}
 
?>" size="16" maxlength="15">
                    <span class="style7">Password              </span>
                    <input name="password" type="password" id="password" size="16" maxlength="15">
                    <br>
                    <input type="submit" name="Submit" value="Submit">
                    </label>
                </form>            </td>
              </tr>
              
          </table></td>
          <td>&nbsp;</td>
        </tr>
      <tr>
        <td height="12"></td>
          <td></td>
          <td></td>
        </tr>
      
      
      
      
      
      
      
      
      
      
    </table></td>
    <td width="1"></td>
  </tr>
  <tr>
    <td width="171" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="http://www.destroi.com/images/addapta/menu_w171_h273.jpg">
      <!--DWLayoutTable-->
      <tr>
        <td width="33" height="25">&nbsp;</td>
          <td width="109">&nbsp;</td>
          <td width="29">&nbsp;</td>
        </tr>
      <tr>
        <td height="224">&nbsp;</td>
          <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <!--DWLayoutTable-->
              <tr>
                <td width="109" height="156" valign="top"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100" height="200">
                  <param name="movie" value="menu.swf">
                  <param name="quality" value="high">
                  <embed src="menu.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100" height="200"></embed>
                </object></td>
              </tr>
              <tr>
                <td height="24">&nbsp;</td>
              </tr>
              
              
              
              
              
              
              
              
              
          </table></td>
          <td>&nbsp;</td>
        </tr>
      <tr>
        <td height="24">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      
      
      
    </table></td>
    <td width="479" height="22" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="http://www.destroi.com/images/addapta/top_w479_h22.jpg">
      <!--DWLayoutTable-->
      <tr>
        <td width="479" height="22">&nbsp;</td>
        </tr>
    </table></td>
    <td></td>
  </tr>
  <tr>
    <td rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="http://www.destroi.com/images/addapta/content_w479_h251.jpg">
      <!--DWLayoutTable-->
      <tr>
        <td width="15" height="251">&nbsp;</td>
          <td width="425" valign="top"><p class="style1"><span class="style2"><span class="style4"><span class="style5"><strong><?PHP 
if ($errormessage != ""){echo "<font color=\"#FF0000\"><strong>$errormessage</strong></font><br>";} ?> Lorem ipsum</strong> <em>dolor sit amet</em>, consectetuer adipiscing elit. Etiam ullamcorper   tempor elit. Donec odio. Proin vitae dolor vitae dolor placerat dignissim. Donec   in mi. Nulla sit amet pede. Curabitur sed est. Mauris at metus. Morbi feugiat   lacus eu turpis. Nunc ultricies posuere urna. Aenean mi urna, facilisis eu,   sodales vel, tincidunt placerat, sem. </span></span></span></p>
            <p class="style3">Phasellus tincidunt diam vel turpis. Vestibulum pretium accumsan sem.   Pellentesque lacinia nisl a lorem. Nam accumsan, nisl id congue rhoncus, justo   velit rhoncus tortor, id malesuada orci augue sit amet massa. Proin tellus pede,   viverra sed, lacinia vel, scelerisque id, nunc. Aenean libero. Suspendisse sed   metus. Etiam rhoncus odio at arcu. Quisque iaculis lacus quis dui semper   rhoncus. Morbi volutpat. Curabitur cursus. Fusce auctor ligula gravida tortor.   Fusce at mi. Aenean eget metus. Integer porta nulla id felis. Sed quis massa. </p>
            <p class="style3">Vivamus luctus quam sit amet ligula. Sed vitae ipsum in libero egestas   aliquam. Morbi quis ante. Nullam odio. Ut eu purus. Duis enim velit, scelerisque   a, egestas at, pharetra sed, orci. Phasellus vestibulum massa id lorem. Nulla mi   risus, posuere ullamcorper, mollis quis, ullamcorper ac, sapien. Aenean quam   libero, venenatis sed, molestie auctor, lobortis eget, velit. Integer gravida   rutrum elit. Sed sed nulla tempus orci tristique mollis. Quisque tincidunt   mollis elit. Aenean quis ante in lorem pulvinar sodales. Vivamus sodales. </p>
            <p class="style3">Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et   malesuada fames ac turpis egestas. Fusce quis est. Aenean rhoncus nonummy   tortor. Nam enim libero, vulputate vulputate, ornare congue, egestas nec,   lectus. Nullam vitae orci quis metus molestie iaculis. Nunc ac pede ac quam   placerat faucibus. Cras pharetra porta nisi. Integer egestas fermentum sapien.   In tempus, justo eget consequat blandit, tortor sapien porttitor dui, vel   dignissim mi nisl non leo. Morbi molestie. </p>
            <p><span class="style3">Nulla molestie massa eget erat. Sed interdum est ac urna. Proin rhoncus justo   nec nibh. In hac habitasse platea dictumst. Sed auctor, libero ac sagittis   pulvinar, eros diam rutrum mi, quis rutrum felis sapien eget massa. Pellentesque   justo sem, varius ut, pharetra fermentum, bibendum placerat, nisi. Mauris   dictum, dui vitae molestie mollis, lorem risus aliquet magna, in aliquam purus   nunc eu neque. Ut justo tortor, vehicula vitae, tincidunt vel, congue ut, metus.   Vivamus porttitor est sed erat. Cras hendrerit. Nullam faucibus. </span><br>
          </p></td>
          <td width="39">&nbsp;</td>
        </tr>
      <tr>
        <td height="14"></td>
          <td valign="top"><div align="center" class="style10"><font face="Verdana" size="1">&copy; Copyright 2006 Jeff Dunn. All rights reserved. </font></div></td>
          <td></td>
        </tr>
      
      
      
    </table></td>
    <td height="251"></td>
  </tr>
  
  <tr>
    <td height="495">&nbsp;</td>
    <td></td>
  </tr>
  <tr>
    <td height="24" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="http://www.destroi.com/images/addapta/bottom_w650_h24.jpg">
      <!--DWLayoutTable-->
      <tr>
        <td width="650" height="24">&nbsp;</td>
        </tr>
    </table></td>
    <td></td>
  </tr>
  <tr>
    <td height="722">&nbsp;</td>
    <td>&nbsp;</td>
    <td></td>
  </tr>
</table>
</body>
</html>');}
}
the page containing this code is saved as a php file.
thanks in advance for the help
destroi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-22-2006, 05:53 PM Re: Echoing PHP code
Experienced Talker

Posts: 40
Location: Denmark
Trades: 0
Why do you want the html inside a die() statement?
dennismp is offline
Reply With Quote
View Public Profile Visit dennismp's homepage!
 
Old 04-22-2006, 10:53 PM Re: Echoing PHP code
Average Talker

Posts: 15
Trades: 0
Because, if I just echo it, it will show both pages

i really need help on this.
it's killing my brain.

Last edited by destroi; 04-23-2006 at 12:13 AM..
destroi is offline
Reply With Quote
View Public Profile
 
Old 04-23-2006, 06:41 AM Re: Echoing PHP code
Experienced Talker

Posts: 40
Location: Denmark
Trades: 0
As I wrote elsewhere, <?php inside die() wont be parsed. (or in any other strnig unless you eval() it)

You can do, as an alternative:
..
else {
print "..";
code..
print "..";
exit; // the script will stop here. so you avoid outputting more stuff.
}
...
dennismp is offline
Reply With Quote
View Public Profile Visit dennismp's homepage!
 
Old 04-24-2006, 04:03 PM Re: Echoing PHP code
Average Talker

Posts: 15
Trades: 0
thanks for the help, making progress, i changed it to this and the error is gone, but it's not printing anytihng.

} else {
print('<?php echo "If this works, its parsing the php"; ?>');
exit();
}

what's wrong?

Last edited by destroi; 04-24-2006 at 04:07 PM..
destroi is offline
Reply With Quote
View Public Profile
 
Old 04-24-2006, 04:17 PM Re: Echoing PHP code
Experienced Talker

Posts: 40
Location: Denmark
Trades: 0
} else {
print('If this works, its parsing the php');
exit();
}
dennismp is offline
Reply With Quote
View Public Profile Visit dennismp's homepage!
 
Old 04-26-2006, 02:49 PM Re: Echoing PHP code
Average Talker

Posts: 15
Trades: 0
Quote:
Originally Posted by dennismp
} else {
print('If this works, its parsing the php');
exit();
}
You don't seem to understand, I want it to print php code, and parse it.
destroi is offline
Reply With Quote
View Public Profile
 
Old 04-26-2006, 05:05 PM Re: Echoing PHP code
Experienced Talker

Posts: 40
Location: Denmark
Trades: 0
Aaah.. Sorry about that.. You can use htmlentities() to convert < to &lt; and > to &gt; in order to avoid the browser parsing it as a (html)tag:

print( htmlentities('<?php echo "If this works, its parsing the php"; ?>'));
dennismp is offline
Reply With Quote
View Public Profile Visit dennismp's homepage!
 
Old 04-27-2006, 01:14 AM Re: Echoing PHP code
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Well i will rather Redirect using the header Function.
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 04-27-2006, 02:50 PM Re: Echoing PHP code
Average Talker

Posts: 15
Trades: 0
Quote:
Originally Posted by Uche
Well i will rather Redirect using the header Function.
Logical, but this will not work for what I am trying to do.
destroi is offline
Reply With Quote
View Public Profile
 
Old 04-27-2006, 02:53 PM Re: Echoing PHP code
Average Talker

Posts: 15
Trades: 0
Quote:
Originally Posted by dennismp
Aaah.. Sorry about that.. You can use htmlentities() to convert < to &lt; and > to &gt; in order to avoid the browser parsing it as a (html)tag:

print( htmlentities('<?php echo "If this works, its parsing the php"; ?>'));
Progress, now it's printing <?php echo "If this works, its parsing the php"; ?>, I need it to parse through the code and print "if this works its parsing the php...
destroi is offline
Reply With Quote
View Public Profile
 
Old 04-27-2006, 04:58 PM Re: Echoing PHP code
Average Talker

Posts: 15
Trades: 0
Tiskkk, I found a way to do it myself, thanks for all the help.

It's pretty common, I actualy knew of it before hand, I just didn't think to use it, and apparently, neither did anyone who read my post.

I did my else, then closed the php, put the html+php code I wanted printed then closed the else after the html+php code I printed.

PHP Code:
} else {
?>
//HTML CODE HERE
//PHP CODE MIXED IN HERE
<?php
exit();
}
}
?>
<?php
//MORE PHP CODE HERE
?>
destroi is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Echoing PHP code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33928 seconds with 12 queries