Trying to include a file.

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

Post Reply
tymlls05
Forum Commoner
Posts: 30
Joined: Tue Nov 01, 2005 1:30 pm

Trying to include a file.

Post by tymlls05 »

This was previously working with include_once. The file I am trying to include creates a list of arrays using a different server.

this.php:

Code: Select all

 
<?
 
$s_time     = "3esh";
$server_name    = "big comp";
$npc_count      = "5";
 
$online_name[]  = "frank";
 
$online_name[]  = "frank2";
 
$online_name[]  = "frank3";
 
$online_name[]  = "frank4";
?>
 
My script calling the file

Code: Select all

<? include_once('this.php')?>
 
<? echo $s_time;?>
 

It just returns nothing at all. just blank.
Last edited by Benjamin on Thu Apr 30, 2009 2:53 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Trying to include a file.

Post by greyhoundcode »

When you say, "The file I am trying to include creates a list of arrays using a different server," do you mean that it is actually on a different box? Like your script calling the file is on http://www.abc.com and the file you are trying to include is on http://www.xyz.com?

Also, is support for short tags enabled?
tymlls05
Forum Commoner
Posts: 30
Joined: Tue Nov 01, 2005 1:30 pm

Re: Trying to include a file.

Post by tymlls05 »

Here, I removed the include and just pasted the file into my script to remove the possibility of include issues.

Code: Select all

<?
 
// include('http://74.196.23.160:2593/newstat.php'); 
 
$s_time     = "2009/04/23 17:16:10";
 
$server_name    = "Dark August";
 
$npc_count      = "16938";
 
$item_count     = "78004";
 
$guild_count    = "8";
 
$client_count   = "3";
 
$memory_usage   = "86300";
 
$admin_email    = "tyler@aimelssmedia.com"; $online_name[]="Malakai"; $online_account[]= "malakai"; $online_name[]="Zato"; $online_account[]= "pasho";
 
 
foreach ($online_account as $v){
echo $v;
}
foreach($online_name as $v) {
echo $v
}
 
 ?>
 
 
Why will that code not echo or print?
Last edited by Benjamin on Thu Apr 30, 2009 2:53 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Trying to include a file.

Post by greyhoundcode »

Problems flagged when I tried your code on my setup were your use of short PHP tags and a missing semi-colon: if you sort those issues then you should find that your echoes work.
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: Trying to include a file.

Post by susrisha »

Code: Select all

 
foreach($online_name as $v) {
echo $v; //you missed a ; here in your code
}
 
 
Post Reply