Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

comparing strings

General discussions related to php

Moderators: macek, egami, gesf

comparing strings

Postby LTLhawk » Wed Apr 30, 2003 3:49 am

Hi,

I am reading a string from a file and searching a database for that string. The strings dont seem to match even though they look the same. When I compare the two they look identical, but the compare isnt satified and I cant figure out why. I echo each variable to the screen and they look identical. Here is a snippet of the code:

// here I get the text from a file
$x=0;
$handle=fopen($filename,"r");
while (!feof ($handle)) {
$player[$x] = fgets($handle,4096);
echo "player[$x]=$player[$x]<br>" ;
$x++;
} // at this point the $player[30]="max"

//here I get the names from the database
while ($myrow = mysql_fetch_array($result)){
if ($myrow['player']==$player[30]){
echo "Player found in db";
//call a function to update the database with
//info about this player

}

}
fclose ($handle1);


Thanks for taking a look.
LTLhawk
New php-forum User
New php-forum User
 
Posts: 29
Joined: Fri Mar 07, 2003 4:17 pm

zero based array

Postby andrewdavey » Tue May 13, 2003 5:56 am

Are you sure you want the 30th element or the 30th index? Since you array will start at index 0, the 30th element is at index 29.

Failing that can I have a look at the data?
andrewdavey
New php-forum User
New php-forum User
 
Posts: 16
Joined: Wed Feb 12, 2003 5:27 am
Location: Cornwall, England

Postby LTLhawk » Tue May 13, 2003 11:38 am

i found the problem..for some reason the the text in the file had an extra character so I strip this char and it all works good..thank you for replying
LTLhawk
New php-forum User
New php-forum User
 
Posts: 29
Joined: Fri Mar 07, 2003 4:17 pm


Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.