check

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

check

Post 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?
peni
Forum Commoner
Posts: 34
Joined: Thu Nov 18, 2004 1:15 pm

Post by peni »

try to output $stats and look how it looks like (whitspaces, etc).
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Post 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
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post 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
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Post 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
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Post 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
Post Reply