my script does this:
$out = ' <div id="morenews"> <h2>more news</h2>
<?php include "../newsblocks/latestnews.php" ?>
</div>'
echo $out
but it doesn't perform the include statement...how do I escape the <?php include "../newsblocks/latestnews.php" ?> so that it performs
$out = ' <div id="morenews"> <h2>more news</h2>
<?php include "../newsblocks/latestnews.php" ?>
</div>'
echo $out
but it doesn't perform the include statement...how do I escape the <?php include "../newsblocks/latestnews.php" ?> so that it performs
-
Re: question..
Thu, November 1, 2007 - 1:01 AMBecause you have the <?php ?> inside the string that is assigned to a variable. Try this instead:
echo '<div id="morenews"><h2>more news</h2>';
include ("../newsblocks/latestnews.php");
echo '</div>'; -
-
Re: question..
Thu, November 1, 2007 - 4:22 AMor if you want to keep your html clraner you could set it up as a function putting the actual logic outside of the html ans rthen simply calling the function... like so...
<?php
function getLatestNews()
{
ob_start(); //open a buffer
include("../newsblocks/latestnews.php"); //include/render the file to the buffer
$latestNews = ob_get_clean(); //empty the buffer contents into a variable
return $latestNews; // return the content of your include
}
?>
<html>
<head><!-- head stuff --></head>
<body>
<!-- whatever comes before this area-->
<div id="morenews">
<h2>more news</h2>
<?php echo getLatestNews(); ?>
</div>
<!-- whever comes after -->
</body>
</html> -
-
Re: question..
Thu, November 1, 2007 - 5:03 AMTrust me I would much rather do it the way you two have suggested. But I cannot get away from the string as it renders the page on event.
I'm using a flash button to play shoutcast streams. This stream is proxied through this script and the tcp stream is chopped and mundged in such a way as the flash audio player thinks it is getting an mp3 data stream. Anyway, I would have to rewrite this all to make either of your ideas work. This is almost becoming a dog chase cat chase rat problem.
Need to sleep on this for abit. Back soon. Thanks. -
-
Re: question..
Thu, November 1, 2007 - 6:21 AMmaybe if you an give us some details of the how thee underlying components work we can help you come to a better solution... -
-
Re: question..
Thu, November 1, 2007 - 1:05 PMsure, it's messy and I am not sure how tribe will render this but here it goes.
<?php
// Settings
$host = "localhost"; // Shoutcast Host
$port = "8000"; // Shoutcast Port
$mount = "/"; // Used for alternate path to "Streaming URL" -- leave as "/" for the default setup.
$icecastInterval = "100"; // Max number of MB to load
$wimpySwf = "/wimpy/wimpy_button.swf"; // Button SWF file name
$width = "70"; // Width of the button
$height = "70"; // Height of the button
$buttonStyle = "square"; // Button style: Can be "circle" or "square";
/////////////////////////////////////////////////
// //
// NO NEED TO EDIT ANYTHING BELOW HERE //
// //
// (unless your a pro) //
// //
/////////////////////////////////////////////////
$newline = "\n";
$streamURL = "http://".$HTTP_SERVER_VARS['HTTP_HOST'].$_SERVER['PHP_SELF'];
$configs = "theFile=".rawurlencode($streamURL."?action=stream")."&icecast=".$icecastInterval."&buttonStyle=".$buttonStyle."&tptBkgd=yes";
$objectID = "wimpybutton";
$action = @$_REQUEST['action'];
if($action == "stream"){
// Make socket connection
$errno = "errno";
$errstr = "errstr";
$fp = fsockopen($host, $port, $errno, $errstr, 30);
// Establish response headers
header("HTTP/1.0 200 OK");
header("Content-Type: audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3");
header("Content-Transfer-Encoding: binary");
// Content-Length is required for Internet Explorer:
// - Set to a rediculous number
// = I think the limit is somewhere around 420 MB
header("Content-Length: 100000000");
// Create send headers
$out = "GET $mount HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n\r\n";
// Write the returned data back to the resource
fwrite($fp, $out);
// Read resource
while (!feof($fp)) {
// Get data in 2048 chuncks
$outData = fgets($fp, 2048);
// Removing shoutcast headers.
if (!stristr($outData, "icy") && !stristr($outData, "content")){
echo $outData;
}
}
fclose($fp);
} else if ($action == "getJavaScript"){
$out = '
// CONFIGS:
wimpySwf = "'.$wimpySwf.'";
icecastInterval = "'.$icecastInterval.'";
width = "'.$width.'";
height = "'.$height.'";
configs = "'.$configs.'";
objectID = "'.$objectID.'";
function writeWimpyButton(){
outputHMTL = "";
outputHMTL += \'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" \';
outputHMTL += \'codebase="download.macromedia.com/pub/sh...0,47,0" \';
outputHMTL += \'width="\'+width+\'" \';
outputHMTL += \'height="\'+height+\'" \';
outputHMTL += \'id="\'+objectID+\'">\';
outputHMTL += \'<param name="movie" value="\'+wimpySwf+\'" />\';
outputHMTL += \'<param name="loop" value="false" />\';
outputHMTL += \'<param name="menu" value="false" />\';
outputHMTL += \'<param name="quality" value="high" />\';
outputHMTL += \'<param name="bgcolor" value="#FFFFFF" />\';
outputHMTL += \'<param name="flashvars" value="\'+configs+\'" />\';
outputHMTL += \'<embed src="\'+wimpySwf+\'" \';
outputHMTL += \'flashvars="\'+configs+\'" \';
outputHMTL += \'width="\'+width+\'" \';
outputHMTL += \'height="\'+height+\'" \';
outputHMTL += \'bgcolor="#FFFFFF" \';
outputHMTL += \'loop="false" \';
outputHMTL += \'menu="false" \';
outputHMTL += \'quality="high" \';
outputHMTL += \'name="\'+objectID+\'" \';
outputHMTL += \'align="middle" \';
outputHMTL += \'allowScriptAccess="sameDomain" \';
outputHMTL += \'type="application/x-shockwave-flash" \';
outputHMTL += \'pluginspage="www.macromedia.com/go/getflashplayer" />\';
outputHMTL += \'</object>\';
document.write(outputHMTL);
//document.write(\'<br><textarea name="textarea" cols="40" rows="10">\'+outputHMTL+\'</textarea><br>\');
}';
echo "$out";
} else {
$out = '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "" title="www.w3.org/TR/xhtml1/DT...-strict.dtd">">www.w3.org/TR/xhtml1/DT...-strict.dtd">
<html xmlns="www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-us" />
<meta name="copyright" content="(c) Copyright 2006 Webgraph" />
<title>KUDO 1080am - Radio Active Talk</title>
<link rel="stylesheet" type="text/css" href="02_styles.css" media="all" />
<link rel="stylesheet" type="text/css" href="sIFR/sIFR-screen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="sIFR/sIFR-print.css" media="print" />
<script src="sIFR/sifr.js" type="text/javascript"></script>
<script src="'.$streamURL."?action=getJavaScript".'" /></script>
</head>
<body class="homepage">
<div id="wrapper">
<div id="content">
<h1 id="logo"><a href="/" title="link to the homepage">KUDO1080am</a></h1>
<div id="content-primary">
<!-- fixes IE 5.5/6 png transparency -->
<!--[if gte IE 5.5]>
<![if lt IE 7]>
<style type="text/css">
#sidebar-tab { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/bg_sidebartab_events.png\');
background-image:none; }
#teaser {
background-image:none;
z-index:10; }
#teaser-ie { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/bg_teaser.png\',sizingMethod=\'crop\');
position:absolute;
left:0;
bottom:0;
width:507px;
height:230px;
bottom:-1px;
z-index:0; }
</style>
<![endif]>
<![endif]-->
<div id="sidebar-tab"></div>
<div id="teaser-ie"></div><!-- #teaser-ie -->
<div id="teaser" class="clearfix">
<div class="channel" id="news"> <h2><span>News</span></h2><img src="/images/onairnow.png" width="122" height="122" alt="" class="fullsize" />
<div class="item summary"><h3>Click Play</h3><SCRIPT LANGUAGE="JavaScript">writeWimpyButton();</SCRIPT><p>Listen live to KUDO 1080am - Radio Active Talk as we discuss the current events, issues and topics of the day.</p><div class="clear"> </div></div> </div>
</div><!-- #teaser -->
</div>
<!-- #content-primary -->
<div id="nav">
</div><!-- #nav -->
</div><!-- #content -->
<div id="sidebar-wrapper">
<div id="sidebar" class="clearfix">
<div class="module" id="mod-events">
<a href="www.google.com/calendar/render target="_blank"><img src="www.google.com/calendar/i...utton2.gif" border=0></a>
</div><!-- .channel -->
</div><!-- #sidebar -->
</div><!-- #sidebar-wrapper --> <div id="footer-wrapper" class="clearfix">
<div id="footer" class="clearfix">
<div id="morenews">
<h2>more news</h2>
<?php include "../newsblocks/latestnews.php" ?>
</div>
<div id="extras">
<div id="external-links">
<a id="myspace" href="visit" title="myspace.com/">visit">myspace.com/">visit our <span>myspace</span></a>
</div>
</div>
</div><!-- #footer -->
</div><!-- #footer-wrapper -->
</div><!-- #wrapper -->
</body>
</html>
';
echo "$out";
}
?> -
-
Re: question..
Thu, November 1, 2007 - 1:29 PM1) See my post below, which repeats the essential point Jory made, which is you don't need the extra <? tags.
2) To post code, it is sometimes good to use pastebin.ca/ which will give you a link you can use in forums and such and won't garble your code. -
-
Re: question..
Thu, November 1, 2007 - 1:38 PMthanks...I think that might work...will test soon.
-
-
-
-
-
-
-
Re: question..
Thu, November 1, 2007 - 7:42 AMIf you're typing $out = ... then you are ALREDAY in PHP context, not HTML context, so you don't need the <?php ... ?> tags to switch to PHP context.
Just concat the included file into the stream you are sending to the variable.
$out = ' <div id="morenews"> <h2>more news</h2>' . include("../newsblock/latestnews.php") . '</div>';
echo $out;