Forum Moderators: coopster

Message Too Old, No Replies

Infamous Parse Error

         

KeithScott

12:15 am on Jan 1, 2006 (gmt 0)

10+ Year Member



Fairly new to php, so learning as I go along.

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/zackpowe/public_html/downloads/test/index.php on line 63

Here is the code including line 63:
<?
$size = 0;
for($i=0;$i<=$count;$i++) {

$file = $file_list[$i];
this is line 63->$path = "/home/url/public_html/downloads/audio/ . $row['username'] . "/";
if ($file!= "index.php" && $file!= "") {
?>
[/code]

Any help would be appreciated and thanks in advance.

Happy New Year

inbound

12:23 am on Jan 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$path = "/home/url/public_html/downloads/audio/ . $row['username'] . "/";

Should be

$path = "/home/url/public_html/downloads/audio/" . $row['username'] . "/";

Simply a missing "

KeithScott

12:38 am on Jan 1, 2006 (gmt 0)

10+ Year Member



WOW! Thanks for the quick reply. I tried that and still getting the same error.

KeithScott

1:00 am on Jan 1, 2006 (gmt 0)

10+ Year Member



Ignore above post. I did get it to work, however, instead of listing the contents of /download/audio/test/ I get a listing of the folders in the audio folder.

Any suggestions on making it access and list the user specific folder?

jatar_k

5:58 am on Jan 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I am guessing then that something is wrng with the value of $row['username']

try putting the path together as you have it then echo it to see what is actually in the var

echo $path;

then, if the path seems right, make sure the directory exists

KeithScott

6:45 am on Jan 2, 2006 (gmt 0)

10+ Year Member



Here is the cleaned code from reading various things on the net. I am still getting parse error

Parse error: parse error, unexpected $ in /home/zackpowe/public_html/downloads/audio2.php on line 113


<?php

//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();

session_start();

//require the config file
require ("/home/zackpowe/public_html/downloads/config.php");
require ("/home/zackpowe/public_html/downloads/functions.php");

// Connect to server and select databse.
mysql_connect("$server", "$dbusername", "$dbpassword")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

// Some functions
while($rows=mysql_fetch_array($result)){

$file_list = getDirFiles("/home/zackpowe/public_html/downloads/audio/" . $row['username'] . "/");

$count = count($file_list);

?>
<table border=0 width=100% bgcolor=0 cellpadding=5 cellspacing=0>
<tr>

<td bgcolor=#eeeeee style="font-family: Tahoma; font-size: 11px;"><b>
File Name (<? echo $rows['username'];?>)
</b></td>
<td bgcolor=#eeeeee style="font-family: Tahoma; font-size: 11px;"><b>
Size
</b></td>
<td bgcolor=#eeeeee style="font-family: Tahoma; font-size: 11px;"><b>
Date
</b></td>

</tr>
<?
$size = 0;
for($i=0;$i<=$count;$i++) {

$file = $file_list[$i];
$path = "/home/zackpowe/public_html/downloads/audio/" . $row['username'] . "/";
if ($file!= "index.php" && $file!= "") {
?>
<tr>

<td bgcolor=#ffffff style="font-family: Tahoma; font-size: 11px;">
<img src="/images/file.gif" align=middle> <a href="/audio/<?=$row['username']?>/<?=$file?>?key=<?=time()?>&validate=md5&log_user=<?=$userid?>"><?=$file?></a>
</td>
<td bgcolor=#ffffff style="font-family: Tahoma; font-size: 11px;">
<?=round(filesize($path . $file)/1024/1024, 2);?> MB
</td>
<td bgcolor=#ffffff style="font-family: Tahoma; font-size: 11px;">
<?=date("m/d/y H:i:s", filectime($path . $file));?>
</td>

</tr>
<?
}

}

function getDirFiles($dirPath)
{
if ($handle = opendir($dirPath))
{
while (false!== ($file = readdir($handle)))
if ($file!= "." && $file!= "..")
$filesArr[] = trim($file);

closedir($handle);
}

@sort($filesArr);
@reset($filesArr);
return $filesArr;
}

function fsize($file){
$size=0;
$range = Array ('B', 'K', 'M', 'G');

if(is_dir($file))
if ($dh = opendir($file)){
while (($filecnt = readdir($dh))!== false) {
if($filecnt == "." ¦¦ $filecnt == "..")continue;
if(is_dir($file."/".$filecnt))
$size += fsize($file."/".$filecnt);
else
$size += filesize($file."/".$filecnt);
echo "\n$file/$filecnt";
}
closedir($dh);
}else
return false;
else
$size = filesize($file);

for ($i = 0; $size >= 1024 && $i < count($range); $i++)
$size /= 1024;

return round($filesize,2).$range[$i];

print("</td></tr></table>");


The error line is above....I am confused....