Page 1 of 1

Having the same strings and diffrenet length

Posted: Sat Apr 03, 2010 4:06 pm
by tina_theod
Hello I'm Tina.

I had an excel document with names of scientists and I put them in my database(MySQL).
I'm reading from .txt files other names and I'm searching to find if a name I have, there is already in my database.
I used the function strcmp() but it doesn't work in case that I have a name that already exists in my database.
Then I used the function strlen() and I discover that having the same name, the lengths of the same names are different!!!
For example,

From my database-> Theocharis, C. R. (String length1: 33)
From .txt files-> Theocharis, C. R. (String length2: 17)

The strcmp() function returns -1 but the names are same and it should return 0.
What I'm going to do??? :)

Re: Having the same strings and diffrenet length

Posted: Sat Apr 03, 2010 4:44 pm
by requinix
The names aren't the same. They just look that way to you.

What if you give the database name to bin2hex and echo the result?

Re: Having the same strings and diffrenet length

Posted: Sat Apr 03, 2010 4:59 pm
by JakeJ
It's possible that you have leading or trailing white space in your list as well. Extra spaces, tabs, etc. Use the trim() function.