943,859 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 902
  • PHP RSS
Sep 7th, 2008
0

Dot in the username is creating problems.

Expand Post »
Hello all,

I have this strange problem.
During registration if user chooses to have '.' in his username, eg: sam.leo then i am getting this wierd problem .

-respective tables with the given username are not getting created in the Database.

Everything is working fine if usernames are having no special characters.
Other than asking users not to use any special characters, how can I solve this!!

Can someone tell me why is this happening and how to get rid off this

Thankyou all in advance.
Last edited by Kavitha Butchi; Sep 7th, 2008 at 10:46 pm.
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
Kavitha Butchi is offline Offline
69 posts
since May 2008
Sep 7th, 2008
1

Re: Dot in the username is creating problems.

We would need to see your code / mysql queries where the rows are being added to the table.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Sep 7th, 2008
0

Re: Dot in the username is creating problems.

Thankyou for the quick reply.

Here is the related code.

php Syntax (Toggle Plain Text)
  1.  
  2. //Code for creating a table --[not wokring when dot is used in username]
  3.  
  4. mysql_connect(" ---") ;
  5. mysql_select_db("---");
  6.  
  7. mysql_query("CREATE TABLE $username(
  8. id INT NOT NULL AUTO_INCREMENT,
  9. PRIMARY KEY(id),
  10. name VARCHAR(30),
  11. order VARCHAR(990),
  12. date datetime NOT NULL default '0000-00-00 00:00:00')");
  13.  
  14.  
  15. mysql_connect("---") ;
  16. mysql_select_db("---");
  17.  
  18.  
  19.  
  20. //creating table another table[-not working when dot is used in username--]
  21.  
  22. mysql_connect("------") ;
  23. mysql_select_db("-----");
  24.  
  25. mysql_query("CREATE TABLE $displayname(
  26. id INT NOT NULL AUTO_INCREMENT,
  27. PRIMARY KEY(id),
  28. likeditem VARCHAR(30))")
  29. ;


-> Tables in a database are not getting created when a dot is used in username.
-> But records are getting created in a table(already created tables which are same for all users)

Everything is working fine when dot is not used.

using=> Godaddy hosting connection, mysql databases.

Please let me know if i need to post anyother details.
Last edited by Kavitha Butchi; Sep 7th, 2008 at 11:28 pm.
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
Kavitha Butchi is offline Offline
69 posts
since May 2008
Sep 7th, 2008
1

Re: Dot in the username is creating problems.

i personally don't recommend making a new table for every user. it may be organized but is difficult to deal with. i would make a users table, then any other tables you would need and you ids to reference info in different tables.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Sep 8th, 2008
0

Re: Dot in the username is creating problems.

I agree with keith. What happens when you have 100 users? You are going to have 100 user tables with one row of data in each. Bad design. All of this could be done with 1-3 properly normalized tables.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Sep 8th, 2008
0

Re: Dot in the username is creating problems.

Click to Expand / Collapse  Quote originally posted by buddylee17 ...
I agree with keith. What happens when you have 100 users? You are going to have 100 user tables with one row of data in each. Bad design. All of this could be done with 1-3 properly normalized tables.
Thankyou fr your time buddylee17.
The individual tables created in my database are used to keep track of all the chat conversations of the user.
I considered that option long before while creating tables with the usernames but was taken back with the idea that it may be well organised rather than creating feilds or records in a single table.
But now seems like there is no other option left and hence shall think abt modifying the structure.

Can someone tell me is there any other solution for this problem?!
Also,
Which one is better?I mean which one is of low burden to the database.

-100 feilds in a table.
-100 records in a table.
-100 tables in a database.

Thankyou all in advance.
Last edited by Kavitha Butchi; Sep 8th, 2008 at 11:25 am.
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
Kavitha Butchi is offline Offline
69 posts
since May 2008
Sep 8th, 2008
1

Re: Dot in the username is creating problems.

Having a dot in the username will not work because most SQL languages use the dot as a relation. So an username like "Jesus.Christ" will try to create a table called 'Christ" in the schema "Jesus". As there is a very low probability of the schema being actually "Jesus", the table creation will fail.
To check, try using your schema.something as username. For example, if your schema is called "MySchema", create an user as "MySchema.NewUser". This should work and create a table called "NewUser" (NOT MySchema.NewUser) in the schema "MySchema".
As for the rest of your question, having a table for each user is not really a good idea. Having a table with 100 fields is even worse. If you need to look up a non-indexed field, the DB Engine will have to read through all 100 fields.
Best solution = 100 records in 1 table, properly indexed. As far as practicable, try normalising the tables so that data-scans are faster.
Reputation Points: 20
Solved Threads: 10
Junior Poster
aparnesh is offline Offline
193 posts
since Jul 2005
Sep 8th, 2008
0

Re: Dot in the username is creating problems.

Got it!!
Thanks a Ton Aparnesh for the detailed explaination.
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
Kavitha Butchi is offline Offline
69 posts
since May 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Trying to display an image rom mysql: whats wrong
Next Thread in PHP Forum Timeline: POST data issue when return to page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC