|
|
locobans
Neurotic (0) Inmate Newly admittedFrom: Insane since: Aug 2004
|
posted 08-20-2004 06:57
Parse error: parse error, unexpected T_STRING in C:\Inetpub\wwwroot\Zion\hbzion 2004\unblock.php on line 50
thats the error and here is the source
---------------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.';
}
}
?>
any tips to manuel_e7@hotmail.com please
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-20-2004 18:42
It looks like you're missing a whole bunch of closing single quotes.
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
.:[ Never resist a perfect moment ]:.
|
Rhino
Bipolar (III) InmateFrom: New Jersey, USA Insane since: Jul 2003
|
posted 08-20-2004 18:50
Quick glance, looks like the problem is that you are not ending your single quotes in about 9 lines and are also missing the semicolons.
for example....
$lines[$locline] = 'character-loc-map = aresden
Hope that helps.
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-21-2004 05:24
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-22-2004 04:15
you need to close the quote and terminate with a semi colon
$lines[$locline] = 'character-loc-map = aresden
to
$lines[$locline] = 'character-loc-map = aresden';
.:[ Never resist a perfect moment ]:.
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-22-2004 08:49
thing is the error is in line 50 right after that line
$lines[$locline] = 'character-loc-x = 200
so that means the lines above that are good
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-22-2004 21:13
No what's happening is that you are opening a single quote on this line
$lines[$locline] = 'character-loc-map = aresden
Which is then getting closed on this line
$lines[$locline] = '( <-- here) character-loc-x = 200
There is no error until the single quote closes and the parser trys to do something with this:
character-loc-x = 200
which is meaningless in php. BTW you need to close the single quote and use the semi-colon on ALL the lines that don't have them.
As a note you will find that frequently in error reporting that the error will actually be above the line listed in the reporting. There are many situations where nothing is technically "broken" until the next line down gets parsed and thats where the error occurs. In PHP whenever you forget a semi-colon the error will always be thrown at the next line down.
.:[ Never resist a perfect moment ]:.
(Edited by bitdamaged on 08-22-2004 21:19)
|
Cameron
Paranoid (IV) InmateFrom: Brisbane Insane since: Jan 2003
|
posted 08-22-2004 23:46
I remember when I was first how to program, I too would often get confused buy these kinds of runtime errors. If you've got a few spare minuites, do some googeling on PHP and Debugging. Also, last I checked the about.com website maintained a good selection fo articles for debugging PHP (the google searches will likely turn up stuff form the PHP Manual, which is good but not great to learn from). Your hour or two of heading will save you days and weeks of wasted time in return.
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-23-2004 06:55
ok i got it fixed but, when i run it, and then put a character name to run the script on it, its change this:
[STATUS]
[COLOR=red]character-loc-map = aresden
character-loc-x = 200
character-loc-y = 120
character-HP = 1452[/COLOR]
to this:
[STATUS]
[COLOR=red]character-loc-map = aresdencharacter-loc-x = 120character-loc-y = 120
character-HP = 1452[/COLOR]
want i want is that its stay all in diferent lines
character-loc-map = aresdencharacter-loc-x = 120character-loc-y = 120
to
character-loc-map = aresden
character-loc-x = 120
character-loc-y = 120
here is my script
<?
Error_reporting(0);
/*---------------Edit this----------------*/
$chardir = 'C:\\Inetpub\\wwwroot\\Zion\\HBserver 3.5\\HBServer 3.2\\Character';
/*-------------Edit this----------------*/
if(!$_POST){
echo '<form action='.$_SERVER['PHP_SELF'].' 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){ $locxline = $a; }
if(substr_count($b, 'character-loc-y') > 0){ $locyline = $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[$locxline] = 'character-loc-x = 120';
$lines[$locyline] = 'character-loc-y = 120';
}
elseif($town == 'elvine'){
$lines[$locline] = 'character-loc-map = elvine';
$lines[$locxline] = 'character-loc-x = 120';
$lines[$locyline] = 'character-loc-y = 120';
}
else{
$lines[$locline] = 'character-loc-map = default';
$lines[$locxline] = 'character-loc-x = 100';
$lines[$locyline] = 'character-loc-y = 100';
}
$lines = chop(implode('', $lines));
$fo = fopen($filename, 'w+');
fwrite($fo, $lines);
echo 'Character successfully un-stuck.';
}
}
?>
reply soon plz
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-23-2004 06:57
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-23-2004 06:58
In html or a text file?
In HTML just add a br tag. In a text file you add a new line \n
$lines[$locline] = 'character-loc-map = aresden\n';
$lines[$locxline] = 'character-loc-x = 120\n';
$lines[$locyline] = 'character-loc-y = 120\n';
.:[ Never resist a perfect moment ]:.
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-23-2004 07:25
perfect instead of getting
character-loc-map = aresdencharacter-loc-x = 120character-loc-y = 120
now i get with \n on it lol
character-loc-map = elvine\ncharacter-loc-x = 120\ncharacter-loc-y = 120\n
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-23-2004 08:06
change the single quotes to double quotes.
.:[ Never resist a perfect moment ]:.
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-23-2004 08:27
$lines[$locline] = 'character-loc-map = aresden\n';
$lines[$locxline] = 'character-loc-x = 120\n';
$lines[$locyline] = 'character-loc-y = 120\n';
to
$lines[$locline] = ''character-loc-map = aresden\n'';
$lines[$locxline] = ''character-loc-x = 120\n'';
$lines[$locyline] = ''character-loc-y = 120\n'';
like that?
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-23-2004 08:58
that didint worked still putting them at the same line
|
Rhino
Bipolar (III) InmateFrom: New Jersey, USA Insane since: Jul 2003
|
posted 08-23-2004 20:10
Was this for an HTML or Text file. By the response of it didn't work, I am going to assume that it is an HTML file. Replace the \n with a <br>
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-23-2004 20:23
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-23-2004 20:39
Your code is PHP but the output isn't and being snarky when people are trying to help you isn't the way to go.
Normally PHP outputs HTML but in this case it looks like you are writing to a text file. The \n should normally insert a line break into text files.
How are you viewing the output?
.:[ Never resist a perfect moment ]:.
|
Tyberius Prime
Paranoid (IV) Mad Scientist with FinglongersFrom: Germany Insane since: Sep 2001
|
posted 08-23-2004 20:58
wouldn't \n only work within double quotes (") instead of single quotes (')?
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-23-2004 21:23
well thing is like this, i run the script in Test123 (character name) then when i run it, its change in a text file, the coordenates of the map that the character is, i alredy tried the \n with double quotes (") any other tips
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-23-2004 23:14
How are you viewing the output file?
.:[ Never resist a perfect moment ]:.
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-23-2004 23:54
|
Rhino
Bipolar (III) InmateFrom: New Jersey, USA Insane since: Jul 2003
|
posted 08-24-2004 00:07
Are you viewing the file in a Browser ?? or Notepad ?? This will help determine why the newline is not being interpreted.
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-24-2004 02:02
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-24-2004 02:02
i edit it in notepad and then link it tru internet explorer
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-24-2004 02:28
Well if you're viewing the file in a browser than you need to insert <br> tags instead of \n (or for clarity both \n<br>
If you view the source of the file in your browser the line breaks should be there.
.:[ Never resist a perfect moment ]:.
|
locobans
Obsessive-Compulsive (I) InmateFrom: Insane since: Aug 2004
|
posted 08-24-2004 04:41
i want that when i apply the php into any character that it MAKES A LINE between character map = blah blah and character location x = balh blah, its not that i want to see it at browser with lines, no it aint that cause i dontknow that lot of php but i know html
|
bitdamaged
Maniac (V) Mad ScientistFrom: 100101010011 <-- right about here Insane since: Mar 2000
|
posted 08-24-2004 08:26
I'm so sick of this thread
(Edited by bitdamaged on 08-24-2004 08:30)
|