Page 1 of 1

check

Posted: Thu Nov 18, 2004 3:09 pm
by SidewinderX
hello ive been looking at it for a wile now and i cant seem to figure out why this stript isnt working..maybe someone else can find my error or explain what im doing wrong

here is the first script which works:
http://24.190.94.106:800/stats/phpform.php~

it does a bunch of stuff and finally displays the final result as $stats

now if you take a look at:
http://24.190.94.106:800/stats/phpform2.php~

its mostley the same script except for the last few lines

Code: Select all

<?php
//Scans for For: and replaces the next line with $player variable
sscanf($stats, 'For: %s' , $player);

//displays results
echo "Player: $player<br>";
?>
what i planed on this doing in the new script is searching in the $stats string for 'For:' and taking the next item in the string and making it a variable (in this case '$player')...once this is done i can call the variable out later in a different place...right now i just put it at the bottom for ease

so my question is how come in the second script (phpform2.php) the $player variable is never displayed?

Posted: Thu Nov 18, 2004 3:51 pm
by peni
try to output $stats and look how it looks like (whitspaces, etc).

Posted: Thu Nov 18, 2004 6:43 pm
by SidewinderX
well in the first one
http://24.190.94.106:800/stats/phpform.php~

$stats is just outputed

to see it in real life go here
http://24.190.94.106:800/stats/phpform.php

and if you want to see the other one

http://24.190.94.106:800/stats/phpform2.php

Posted: Thu Nov 18, 2004 7:16 pm
by rehfeld
i only looked at your code for about 10secs, but the first thing i wondered was does the string actually have the word "FOR:" in it ??? try echoing it out before calling scanf on it to see

it looks like you did an str_replace and removed the space following it, making your pattern to match fail

Posted: Thu Nov 18, 2004 7:58 pm
by SidewinderX
rehfeld wrote:the first thing i wondered was does the string actually have the word "FOR:" in it ???
when i just do echo"$sats" this is the result
For:
OAD-Sidewinder
Rank:
5-Star General ( 18 )
PCID:
A-SG-W26EH8
This player is a member of the NovaWorld Communities Overall
Statistics
Base Targets Destroyed
895
Flags Captured
'For:' being the first thing in there

as for the str_replace i just did that so the format would be as follows:

For:
OAD-Sidewinder

instead of For: OAD-Sidewinder

Posted: Thu Nov 18, 2004 8:01 pm
by SidewinderX
bingo i got ....i think i may have read your post wrong...i just omited the For from the str_replace it it worked...thanks