Forum Moderators: coopster

Message Too Old, No Replies

Parse error: parse error, unexpected T_STRING in C:\Inetpub\wwwroot\Zi

Parse error: parse error, unexpected T_STRING in C:\Inetpub\wwwroot\Zion\hb

         

locobans

5:10 am on Aug 20, 2004 (gmt 0)



Parse error: parse error, unexpected T_STRING in C:\Inetpub\wwwroot\Zion\hbzion 2004\unblock.php on line 50

source file:

---------------Edit this----------------*/
$chardir = 'C:\\Inetpub\\wwwroot\\Zion\\HBserver 3.5\\HBServer 3.2\\Character';
/*-------------Edit this----------------*/
if(!$_POST){
echo '<form action=unstick2.php method=post>Character:<input type=text name=char><br><input type=submit value=Submit></form>';
}
else{
$fl = substr($_POST['char'], 0, 1);
$ascii = ord($fl);
$filename = $chardir . '\\ASCII' . $ascii . '\\' . $_POST['char'] . '.txt';
if(!is_readable($filename)){ echo 'Character does not exist.'; }
else{
$lines = file($filename);
$a=0;
foreach($lines as $b){
if(substr_count($b, 'character-location') > 0){ $townline = $a; }
if(substr_count($b, 'character-loc-map') > 0){ $locline = $a; }
if(substr_count($b, 'character-loc-x') > 0){ $locline = $a; }
if(substr_count($b, 'character-loc-y') > 0){ $locline = $a; }
$a++;
}
$town = str_replace(' ', NULL, $lines[$townline]);
$town = str_replace('character-location=', NULL, trim($town));
if($town == 'aresden'){
$lines[$locline] = 'character-loc-map = aresden
$lines[$locline] = 'character-loc-x = 200
$lines[$locline] = 'character-loc-y = 200
';
}
elseif($town == 'elvine'){
$lines[$locline] = 'character-loc-map = elvine
$lines[$locline] = 'character-loc-x = 200
$lines[$locline] = 'character-loc-y = 200
';
}
else{
$lines[$locline] = 'character-loc-map = default
$lines[$locline] = 'character-loc-x = 100
$lines[$locline] = 'character-loc-y = 100
';
}
$lines = chop(implode('', $lines));
$fo = fopen($filename, 'w+');
fwrite($fo, $lines);
echo 'Character successfully un-stuck.';
}
}
?>

what should be wrong?

Spook

6:33 am on Aug 20, 2004 (gmt 0)

10+ Year Member



Hello and welcome locobans.

First thing I notice is that you do not have an opening <?php at the top of your code [Though this could be a cut 'n' paste error].

Secondly [and I am probably the least qualified person to be offering advice around here], to locate an error like this one I usually start by commenting out lines/blocks of code from the end of the script and working backwards. When the error changes will give you a good idea where the problem is. Oh, don't comment out the closing?> though.

Thing is, when learning php, you get a lot of experience in finding mistakes!

Spook

dreamcatcher

7:04 am on Aug 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Which is line 50?

Timotheos

8:47 am on Aug 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if($town == 'aresden'){
$lines[$locline] = 'character-loc-map = aresden
$lines[$locline] = 'character-loc-x = 200
$lines[$locline] = 'character-loc-y = 200
';
}

These lines look weird to me. The single ' is going to throw errors.

jatar_k

3:53 pm on Aug 20, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$lines[$locline] = 'character-loc-map = aresden
$lines[$locline] = 'character-loc-x = 200
$lines[$locline] = 'character-loc-y = 200
';
}
elseif($town == 'elvine'){
$lines[$locline] = 'character-loc-map = elvine
$lines[$locline] = 'character-loc-x = 200
$lines[$locline] = 'character-loc-y = 200
';
}
else{
$lines[$locline] = 'character-loc-map = default
$lines[$locline] = 'character-loc-x = 100
$lines[$locline] = 'character-loc-y = 100
';
}

all of that is your problem. I really don't know how to suggest a fix because I really have no clue what you are shooting for.

I see 2 possibilities, I will use the following line for example.

$lines[$locline] = 'character-loc-map = elvine

1. you are trying to assign the string to the var $lines[$locline]. You would need to make 2 changes then.

$lines[$locline] = 'character-loc-map = elvine';
and subsequent lines would need .= or the new value would overwrite the previously assigned one.

2. you are creating a multi dimensional array

the syntax change would be as follows then
$lines[$locline]['character-loc-map'] = 'elvine';

I am really not sure if either of these is right but with a little more informatin we can figure it out.