PDA

View Full Version : Parse error: syntax error, unexpected T_VARIABLE


leekheed
04-18-2012, 01:23 PM
hi there, learning php (well trying to) and getting the error (Parse error: syntax error, unexpected T_VARIABLE on line 3.... could some possible help.. thanks for your time :@)

$allLines = file(".htCounter.csv");
while($line=array_pop($allLines)) {
list($url,$count) = split(":" $line);
$count = rtrim($count);
$counts[$url] = $count;
}

xdeath
04-19-2012, 05:19 AM
the variable "T_VARIABLE" isn't even in the code you shown us. so there either more code there your not showing us or its refering to a variable in another file which you didn't provide or show us.

regardless we can't help you with what you've provided. unless of course you know a way i can read peoples minds in which case then i could. ;)

leekheed
04-19-2012, 04:44 PM
here is the full script, thought it would be easier to post the lines were i thought the error was, thanks for the quick response :@)

<?php
if (!empty($_SERVER['HTTPS'])=="" or $_SERVER['HTTPS']=="off") {
$url_page_to_count = "";
} else {
$url_page_to_count = "";
}
$url_page_to_count = $url_page_to_count . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];


$allLines = file(".htCounter.csv");
while($line=array_pop($allLines)) {
list($url,$count) = split(":" $line);
$count = rtrim($count);
$counts[$url] = $count;
}

if ($counts[$url_page_to_count] > 0) {
$counts[$url_page_to_count]++;
$fh = fopen(".htCounter.csv", "w");
if (flock($fh, LOCK_EX)) {
foreach ($counts as $url=>$count) {
fwrite($fh, "$url,$count\n");
}
flock($fh, LOCK_UN);
}
fclose($fh);
$count = $counts[$url_page_to_count];
} else {
$fh = fopen(".htCounter.csv", "a");
if (flock($fh, LOCK_EX)) {
fwrite($fh, "$url_page_to_count,1\n");
flock($fh, LOCK_UN);
}
fclose($fh);
$count=1;
}

?>

fruitbeard
04-19-2012, 07:28 PM
Hi,

try putting

list($url,$count) = split(":", $line)

instead of

list($url,$count) = split(":" $line)

maybe it will help

my hobby - fgps.com/keith

leekheed
04-20-2012, 04:11 PM
thanks for taken the time to help me, it worked but it has now given me the same error on line 13 !!

fruitbeard
04-21-2012, 09:35 AM
Hi,

msybe use this code instead of the other one as it's deprecated in higher versions of php.


list($url,$count) = explode(",", $line);


instead of


list($url,$count) = split(":", $line)


i get no errors testing here

leekheed
04-21-2012, 02:18 PM
thanks for you time and help, everything seems to working fine now, again thanks :@)