|
 Larry Hart - 2005-06-17 12:37:41
Error when I run Example.php
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'
any advice?
Larry
 Er. Rochak Chauhan - 2005-06-17 12:49:38 - In reply to message 1 from Larry Hart
Hey Larry !
First of all I am assuming that you are not trying to campare DOC or PDF files. Secondly, could you please specify the line number too ? I have checked it on UNIX and WINDOWS platform (usinf ASCII FILES Only) and not errors where encountered.
Please lemme know which files (type) are you tryin to compare
Rochak
 Er. Rochak Chauhan - 2005-06-17 12:54:53 - In reply to message 1 from Larry Hart
I am sorry bout that ... I thought you were talkin bout my file comparison class... Sorry Larry....
Coming back to your query....if you could tell me how you are using the class... i mean the code in example.php... it would be easy for be to debug..
BTW... here's another example :
require_once('CountryFromIP.inc.php');
$object = new CountryFromIP();
$ip ='210.25.55.2';
$countryName = $object->GetCountryName($ip);
$flagPath = $object->ReturnFlagPath();
 Larry Hart - 2005-06-17 20:21:12 - In reply to message 3 from Er. Rochak Chauhan
Hi Rochak
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/MYSITE/public_html/IPTOCountry/CountryFromIP.inc.php on line 11
Hope this helps
Larry :)
 Er. Rochak Chauhan - 2005-06-18 06:06:08 - In reply to message 4 from Larry Hart
Let me guess... you are not using php5 right ?? must be php 4 or around... if yes... then just do one thing.... replace all "Private" in the class source by "Public" .
 Larry Hart - 2005-06-18 08:03:44 - In reply to message 5 from Er. Rochak Chauhan
Yes I am using PHP Version 4.3.11 :)
Even though I have changed the private to public statements I am getting this error...
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/MYSITE/public_html/IPTOCountry/CountryFromIP.inc.php on line 11
Just as a test I removed line 11 and the error moved to line 12. When I removed that line the error moved to line 22
 Er. Rochak Chauhan - 2005-06-18 16:40:29 - In reply to message 6 from Larry Hart
Buddy replace all "PRIVATE" to "PUBLIC" in the whole class ... okkay ?
 Giuseppe Avella - 2005-06-20 10:46:00 - In reply to message 6 from Larry Hart
Hello,
the error comes from the fact the you can't do any assignement in the declaration class:
(sic)
class CountryFromIP {
private $CountryIPDatabase = 'CountryIPDatabase.txt';
private $ip = '';
...
(sic)
To avoid the problem:
1) remove all the private (and public) statements.
2) remove the assignemets.
3) declare two local variables members and add the class constructor as follows:
class CountryFromIP {
var $CountryIPDatabase;
var $ip;
// Constructor
function CountryFromIP($CountryIPDatabase = 'CountryIPDatabase.txt')
{
$this->CountryIPDatabase = $CountryIPDatabase;
$this->ip = '';
}
Now it should work.
Best regards,
Giuseppe
 Dide Syarif - 2005-06-21 21:44:27 - In reply to message 8 from Giuseppe Avella
This code, work for me
<?Php
/**
* This class generates the country name and its flag from its IP address
*
*
* @author Rochak Chauhan
*/
class CountryFromIP {
var $CountryIPDatabase = "CountryIPDatabase.txt";
var $ip = "";
function ValdateIP($ip) {
$ipArray = explode(",",$ip);
if(count($ipArray) != 4) {
echo "<font color='red' size='3'> <b>ERROR: </b> Invalid IP</font>";
return false;
}
else {
return true;
}
}
function GetCountryName($ip) {
$this->ip = $ip;
$ip = sprintf("%u", ip2long($ip));
$csvArray = file($this->CountryIPDatabase);
for($i=0; $i<count($csvArray); $i++) {
$arrayOfLine = explode(",", $csvArray[$i]);
if($ip >= $arrayOfLine[0] && $ip <= $arrayOfLine[1] ) {
return $countryName = $arrayOfLine[2];
}
}
return false;
}
function ReturnFlagPath() {
if($countryName = trim(ucwords(strtolower($this->GetCountryName($this->ip))) )) {
return "flag/$countryName.gif";
}
else {
return false;
}
}
}
?>
 Dide Syarif - 2005-06-21 21:48:38 - In reply to message 9 from Dide Syarif
Example :
<?php
require_once("CountryFromIP.inc.php");
$ip =$HTTP_SERVER_VARS['REMOTE_ADDR'];
$object = new CountryFromIP();
$countryName = $object->GetCountryName($ip);
$flagPath = $object->ReturnFlagPath();
echo "<BR> <B>Country: </B>".$countryName;
echo "<BR> <B>Flag: </B> <img src=".$flagPath." border='0'>";
?>
I use this script at http://www.torche-indonesia.com/~dieds/dieds_gold/
Thank You Rochak, nice class
|