Strange but True

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

jkmcgrath
Forum Commoner
Posts: 33
Joined: Mon May 05, 2003 10:07 am

Strange but True

Post by jkmcgrath »

Ok check this out.

Code: Select all

<html>
<head>
<title>New Page 1</title>
</head>
<body>
<?php include("http://mo-avcrad-fs01/invision/ssi.php?a=lasttopics"); ?>
<?php include("http://mo-avcrad-fs01/invision/ssi.php?a=stats"); ?>
<?php include("invision/hitsfile.txt"); ?>
</body>
</html>
I save as test.php go to it in the browser and I get "10" which is in the hitsfile.txt but nothing else at all.

I can take each of the include addresses and put them in address bar and they display as should be.

This is on IIS5 so I dont know if that has anyting to do with it or not. PHP v4.2.3.

Any ideas why the php includes will not show but the txt does?

Thanks
John
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

that's not a valid url. What are you trying to do?
jkmcgrath
Forum Commoner
Posts: 33
Joined: Mon May 05, 2003 10:07 am

Intranet

Post by jkmcgrath »

That is a url to my units intranet server.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

ok, then it's difficult for me to test ;)
if you put

Code: Select all

<?php error_reporting(E_ALL); ini_set('display_errors', TRUE); ?>
before the first include block is there any error raising?
What if you do the same in ssi.php (for debug purposes only).
If you enable the access-log on \\mo-avcrad-fs01's IIS (but I forgot where this setting was) does the request show up there?
jkmcgrath
Forum Commoner
Posts: 33
Joined: Mon May 05, 2003 10:07 am

ahhhhhhh

Post by jkmcgrath »

Warning: Failed opening 'http://mo-avcrad-fs01/invision/ssi.php?a=lasttopics' for inclusion (include_path='.;c:\php4\pear') in c:\inetpub\wwwroot\test.php on line 28

Warning: Failed opening 'http://mo-avcrad-fs01/invision/ssi.php?a=stats' for inclusion (include_path='.;c:\php4\pear') in c:\inetpub\wwwroot\test.php on line 29


So that is an issue in my php.ini correct?

In the end this is for trying to get a javascript variable to run which I will post once I have this resolved. :roll:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

either it's not able to resolve the host's name or url_wrappers might be disabled.

http://www.php.net/manual/en/ref.filesy ... -url-fopen
IIRC it effects include(),require(),... as well
jkmcgrath
Forum Commoner
Posts: 33
Joined: Mon May 05, 2003 10:07 am

Still no luck

Post by jkmcgrath »

I still havent gotten it to work. It is a setting in the php.ini I am sure and I will find it some day lol :)

BUt in the mean time I can use iframes to get around it :lol:


But here is the javascript problem I am having.

I have read the sticky topcs on this subjuect pluys many others but still cannot get it right.

Code: Select all

<script language"javascript" src="scroll.js" type="text/javascript"></script>
<html>
<head>
<title>New Page 1</title>
<style type="text/CSS">
  .scrollClass &#123;
    text-align:center;
    font:normal 8pt Arial,sans-serif;
  &#125;
</style>
</head>
<body onLoad="scroller1.scroll();">
<?php 
error_reporting(E_ALL); ini_set('display_errors', TRUE);

$test = "test";
?> 

<?PHP echo '<script language"javascript" type="text/javascript">
<!--
test = <?PHP echo($test);?>
var scroller1 = new scrollObject("scroller1", "MainName", 120, 120, "white", 1, 60, 30, 0, "scrollClass");
scroller1.block&#1111;1] = "<iframe src=http://mo-avcrad-fs01/invision/ssi.php?a=stats width=150 height=300 frameborder=0></iframe>";
scroller1.block&#1111;1] = "<iframe src=http://mo-avcrad-fs01/invision/ssi.php?a=lasttopics width=150 height=300 frameborder=0></iframe>";
scroller1.block&#1111;2] = "<iframe src=http://mo-avcrad-fs01/invision//ssi.php?a=active width=150 height=300 frameborder=0></iframe>";
scroller1.block&#1111;3] = "'document.write(test)'";
scroller1.block&#1111;4] = "Easy to configure, easy to run, with content automatically centred horizontally and vertically";
scroller1.block&#1111;5] = "Have any number of block scrollers running on a single page all with a single JavaScript";
scroller1.block&#1111;6] = "View the source for more info!";
//-->
</script>'
?>
<?php include("http://dfseals.net/invision/ssi.php?a=lasttopics"); ?>
<?php include("http://mo-avcrad-fs01/invision/ssi.php?a=stats"); ?>
<?php include("invision/hitsfile.txt"); ?>
<iframe src="http://mo-avcrad-fs01/invision/ssi.php?a=lasttopics" width="150" height="300" frameborder="0"></iframe>
<div id="MainName">
  The contents of this block will be displayed if the browser does not support the scroller.
  It will be overwritten if the scroller is supported.
</div>
</body>
</html>
I have tried several ways to pull the variable out of php so it will show up in a scrolling block but no luck on that either.

Any ideas on this one?

Here is the scroller.js code

Code: Select all

var scObj1 = new scrollObject("scObj1", "sMain", 120, 120, "white", 1.45, 3, 30, 5000, "scrollClass");

scObj1.block&#1111;0] = "This is block 1";
scObj1.block&#1111;1] = "This is block 2, which appears five seconds later";
scObj1.block&#1111;2] = "Blocks can contain any HTML including:";
scObj1.block&#1111;3] = "Images, tables, links and more";
scObj1.block&#1111;4] = "Easy to configure, easy to run, with content automatically centred horizontally and vertically";
scObj1.block&#1111;5] = "Have any number of block scrollers running on a single page all with a single JavaScript";
scObj1.block&#1111;6] = "View the source for more info!";


var scObj2 = new scrollObject("scObj2", "sMain2", 60, 468, "aliceblue", 1.44, 3, 30, 3000, "scrollClass");

scObj2.block&#1111;0] = "<a href="http://www.greywyvern.com" target="_top"><span style="font:bold 36pt fantasy;">Visit GreyWyvern.com!</span></a>";
scObj2.block&#1111;1] = "<a href="http://www.greywyvern.com/forum.php" target="_top"><span style="font-weight:bold;">Home of the GWForum, and webring script (in development)</span></a>";
scObj2.block&#1111;2] = "<a href="http://www.greywyvern.com" target="_top"><img src="http://www.greywyvern.com/img/nav/banner468x60.jpg" border="0"/></a>";

/* **************************************************************************
*** Don't pass this line ****************************************************
************************************************************************** */
function scrollObject(objName, main, height, width, bkgcol, deccel, begin, speed, pause, classname) &#123;
  this.objName = objName;
  this.main = main;
  this.one = main + "Block1";
  this.two = main + "Block2";
  this.block = new Array();
  this.blockup = 1;
  this.height = height;
  this.width = width;
  this.bkgcol = bkgcol;
  this.deccel = Math.max(deccel, 1);
  this.begin = Math.max(Math.min(begin, this.height), 1);
  this.speed = speed;
  this.pause = pause;
  this.slide = height / this.begin;
  this.table = "<table cellpadding="0" cellspacing="0" border="0"><tr><td class="" + classname + "" style="width:" + width + "px;height:" + height + "px;">";
  this.scroll = scroll;
  this.scrollLoop = scrollLoop;
&#125;

function scroll() &#123;if (!document.getElementById) return false;
  document.getElementById(this.main).innerHTML = "<div id="" + this.one + ""></div><div id="" + this.two + ""></div>";
  var divList = &#1111;document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
  for (var i = 0; i <= 2; i++) &#123;
    if (i > 0) &#123;
      divList&#1111;i].style.position = "absolute";
      divList&#1111;i].style.left = "0px";
      (i == 1) ? divList&#1111;i].style.top = "0px" : divList&#1111;i].style.top = this.height + "px";
      divList&#1111;i].innerHTML = this.table + this.block&#1111;i - 1] + "</td></tr></table>";
    &#125; else &#123;
      divList&#1111;i].style.position = "relative";
      divList&#1111;i].style.background = this.bkgcol;
    &#125;
    divList&#1111;i].style.width = this.width + "px";
    divList&#1111;i].style.height = this.height + "px";
    divList&#1111;i].style.overflow = "hidden";
  &#125; setTimeout(this.objName + ".scrollLoop();", this.pause);
&#125;

function scrollLoop() &#123;
  var divList = &#1111;document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
  for (var j = 1; j <= 2; j++) divList&#1111;j].style.top = (parseInt(divList&#1111;j].style.top) - this.slide) + "px";
  this.slide = Math.max(parseInt(this.slide / this.deccel), 1);
  if (Math.min(parseInt(divList&#1111;1].style.top), parseInt(divList&#1111;2].style.top)) <= -this.height) &#123;
    this.slide = this.height / this.begin;
    if (++this.blockup >= this.block.length) this.blockup = 0;
    var wDiv = (parseInt(divList&#1111;1].style.top) <= -this.height) ? 1 : 0;
    divList&#1111;2 - wDiv].style.top = this.height + "px";
    divList&#1111;2 - wDiv].innerHTML = this.table + this.block&#1111;this.blockup] + "</td></tr></table>";
    divList&#1111;1 + wDiv].style.top = "0px";
    setTimeout(this.objName + ".scrollLoop();", this.pause);
  &#125; else setTimeout(this.objName + ".scrollLoop();", this.speed);
&#125;
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post by Tubbietoeter »

include can only include local files not web files

you could do a frameset and load the file into the frame


or you could use session variables and include the local file which also uses your session variables. so it doesnt get the values by GET
jkmcgrath
Forum Commoner
Posts: 33
Joined: Mon May 05, 2003 10:07 am

Post by jkmcgrath »

Roger that thank you

John
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

include can fetch remote files (like fopen) but you will receive what the remote system offers you. In case of a php-aware webserver you only get the output of that script, just like you've opened the document in your browser.
jkmcgrath
Forum Commoner
Posts: 33
Joined: Mon May 05, 2003 10:07 am

passing the varible to javascript

Post by jkmcgrath »

I read the sticky topics concerning this and I am still dazed and confused. 8O


Would it be possible to have an example of how to pass the var $test into the javascript below. In one of the (scroller1.block[6] = " $test " ; )

Code: Select all

<script language"javascript" src="scroll.js" type="text/javascript"></script>
<html>
<head>
<title>New Page 1</title>
<style type="text/CSS">
  .scrollClass &#123;
    text-align:center;
    font:normal 8pt Arial,sans-serif;
  &#125;
</style>
</head>
<body onLoad="scroller1.scroll();">

<?PHP 
$test = "test"

echo '<script language"javascript" type="text/javascript">
<!--
var scroller1 = new scrollObject("scroller1", "MainName", 140, 125, "#cdcdcd", 1.45, 3, 30, 2000, "scrollClass");
scroller1.block&#1111;0] = "<img src=images/pullups.gif>";
scroller1.block&#1111;1] = "Have you got what it takes?";
scroller1.block&#1111;2] = "<img src=images/jumping_jacks.gif>";
scroller1.block&#1111;3] = "The burning desire to excell?";
scroller1.block&#1111;4] = "<img src=images/pushups.gif>";
scroller1.block&#1111;5] = "THe MO_AVCRAD does!";
//-->
</script>'
?>

<div id="MainName">
  The contents of this block will be displayed if the browser does not support the scroller.
  It will be overwritten if the scroller is supported.
</div>
</body>
</html>
Thanks again for your help guys

John
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

...
<?php
$test = "test";
?>
<script language"javascript" type="text/javascript">
<!--
	var scroller1 = new scrollObject("scroller1", "MainName", 140, 125, "#cdcdcd", 1.45, 3, 30, 2000, "scrollClass");
	scroller1.block[0] = "<img src=images/pullups.gif>";
	scroller1.block[1] = "Have you got what it takes?";
	scroller1.block[2] = "<img src=images/jumping_jacks.gif>";
	scroller1.block[3] = "The burning desire to excell?";
	scroller1.block[4] = "<img src=images/pushups.gif>";
	scroller1.block[5] = "THe MO_AVCRAD does!";
	scroller1.block[6] = "<?php echo $test; ?>";
//-->
</script>
?>

<div id="MainName">
...
jkmcgrath
Forum Commoner
Posts: 33
Joined: Mon May 05, 2003 10:07 am

I tried this

Post by jkmcgrath »

<?PHP
$test = "test";
?>

<script language"javascript" type="text/javascript">
<!--
var scroller1 = new scrollObject("scroller1", "MainName", 140, 125, "#cdcdcd", 1.45, 3, 30, 2000, "scrollClass");
scroller1.block[0] = "<img src=images/pullups.gif>";
scroller1.block[1] = "Have you got what it takes?";
scroller1.block[2] = "<img src=images/jumping_jacks.gif>";
scroller1.block[3] = "The burning desire to excell?";
scroller1.block[4] = "<img src=images/pushups.gif>";
scroller1.block[5] = "THe MO_AVCRAD does!";
scroller1.block[6] = "<?PHP echo $test; ?>";
//-->
</script>
And it still comes up blank. :cry:

It is really getting the best of me lol
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

blank it what way?
The scrollerObject does not show up or the browser's source view showed scroller1.block[6] = "";?
jkmcgrath
Forum Commoner
Posts: 33
Joined: Mon May 05, 2003 10:07 am

sorry

Post by jkmcgrath »

I just resaved the file and it works now like a charm!


Thank you so very much!

Now if I can get it to pass from page to page :)
Post Reply