FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


displaying from array





imagefree
I am making a website with different directories for each member. personal directory of each member contains stats file (m_stats.txt) in php format (<?php ?>)

here is one:
Code:

<?php
   $m_stats[206][time][]="1208842123";
   $m_stats[206][ip][]="127.0.0.1";
   $m_stats[206][iip][]="";
   $m_stats[206][agent][]="Opera/9.26 (Windows NT 5.1; U; en)";
   $m_stats[206][port][]="4162";
   $m_stats[206][via][]="";
   $m_stats[206][ref][]="http://localhost/sitename/login.php";
   ?>

These are the stats when the user registers.
Here is the directory where such files are kept.
Code:
"sitename/members/$a/m_stats.txt";


$a means the user's personal id. Each user have own directory with personal id.

Now when i print this file with the following code, it produces no error but the output contains just <html</html>



Code:
echo "<table>";
for($a=205;$a<231;$a++)
{
   $file="sitename/members/$a/m_stats.txt";
   if(is_file($file))
   include($file);
   //else echo "File: $file does not exist.";
   for($count=0;$count<count($m_stats[$a][time]);$count++)
   {
      //echo $m_stats[$a][ip][$count];
      echo "<tr><td>".$m_stats[$a][ip][$count].
           "</td><td>".$m_stats[$a][iip][$count]."</td><td>".$m_stats[$a][agent][$count].
           "</td><td>".$m_stats[$a][port][$count]."</td><td>".$m_stats[$a][via][$count].
           "</td><td>".$m_stats[$a][ref][$count]."</td><td>".strftime('%B %d, %Y, %A  %I:%M:%S %p',$m_stats[$a][time][$count])."</td></tr>";
   }

}
echo "</table>";

This code is kept outside of the 'sitename' directory, ie ../

Please help me displaying such data. (Data is, as shown in code 1, a php array).

Thanks
sonam
First, if your file have txt extension then you don't need <?php and ?>. second, if you are using txt file then include will not produce array. If you need array then, I think, simplest way is to change txt extension in php. I haven't time for try and I cannot quaranty. Wink

Sonam
Related topics
Interview: Derek Liu, Gaia Online Anime Community
Trouble displaying Adsense.
.htaccess problem
[PHP] Faking Shell Access Through PHP
Java tutorials
[php] array reference
how to accept array variable from a form in Perl
how to handle post data as an array
Displaying Files...
AJAX tutorial [2nd part now updated]
howto: Array ??
PHP Calendar Bug
passing javascript array
PHP has stopped displaying my nav
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.