Hi,

I am looking for some information about using Underscores ( _ ) in usernames. I currently have a friends system where a user can become friends with another user and this is placed into a database.

I then have a query to display all of the users friends, which works totally fine, unless the user has an underscore in their name. It does not matter where it lays my programme does not like it for example:

_AdriftUniform
Adrift_Uniform
AdriftUniform_

None of these examples will be picked up on, but any username without an underscore will work fine.

The annoying thing is that names with underscores will work everywhere else in the website weather it is echoing the username, using it in the url or saving it in a database along side an uploaded image, Just not with my friends system.

I hope someone can help me understand why this is not working. I am available to show code is needs be.

Thanks,
AdfirtUniform.

Recommended Answers

All 4 Replies

Have you tried replacing the underscores with its html entity code?
In this case underscore is:

& # 9 5 ;

(without the spaces) See here
Might be worth a try...

I have not tried this no, but I do not know how I would implement it as the Usernames are User generated. I cant really ask the users to type & # 9 5 ; instead of an underscore.

Any ideas of how I can convert it before it goes into the database perhaps?

The annoying thing is that names with underscores will work everywhere else in the website weather it is echoing the username, using it in the url or saving it in a database along side an uploaded image, just not with my friends system.

This should tell you already that the problem lies within the friends system. Anyway, it would be hard to locate the problem without code.

This problem is fixed now, I have no idea how it is fixed, I just began work on this the next day and all of a sudden it was working. Very strange!

Thanks for all your help guys.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.