if ($row[0] == $name){
$uID = $uID + 1;
}else{
mssql_query("INSERT INTO index_chessbrain (uID, name, team, country) VALUES ($uID, '$name', '$team', '$country')");
$uID = $uID + 1;
}
I wouldn't mind doing that, but there is definitly a problem in the if statement. If $row[0] == $name turns out to be false all the time whether the select statement returns a value or not, then I'll have many duplicate entries from the trailing else statement. I haven't fooled with it any more since early this morning, because I'm at work, but I'll be sure to get back to you guys this evening with results of using the else statement instead of an else if. I wanted to stay away from using an else statement, I feel they have a better chance to be buggy, but I'll give it a shot.
===========================================
Last night I did decide to try to the script with a hard-coded name that was not obtained through the fscanf method and it worked as it should. I inserted the information for Supp in the database and executed this simpler script to make sure the data stored in the array could be evaluated against a variable containing a string.
$name = "Supp"
$check = mssql_query("SELECT name FROM index_chessbrain WHERE name LIKE 'Supp'");
while ($row = mssql_fetch_array($check)) {
if ($row[0] = $name){
echo "$name";
}
}
fclose($handle);
As it expected it passed the if statement and echoed his name. When I removed his record from the database, it failed and nothing was done. Then I went back to the original script and put an
echo "$name";
statement directly following the
while ($userinfo = fscanf ($handle, "%[^\t]\t%[^\t]\t%[^\t]\t%[^\n]\n")){
list ($name, $team, $country) = $userinfo;
and it correctly displayed each name that was parsed into the $name variable on each pass of the while loop.
/me scratches his head in dismay
I'm lost for words