Colourtheory Posted December 19, 2012 Share Posted December 19, 2012 How do I fix this error? I'm pasting the SQL part but if you need the PHP part ask. $acc = "CREATE TABLE $_POST[username](Username varchar(15),Password varchar(15),Email varchar(15),Age int)" Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2012 Share Posted December 19, 2012 What exactly is the error? Are you validating that $_POST['username'] is a valid table identifier? Link to comment Share on other sites More sharing options...
Colourtheory Posted December 19, 2012 Author Share Posted December 19, 2012 Yes, that's the name. The error is here: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE ( Username varchar(15), Password varchar(15), Email varchar(15), A' at line 1 Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2012 Share Posted December 19, 2012 Sounds like the username is empty. You need to validate that to make sure it is a valid MySQL table identifier before trying to run the query. If you want to use user input as a MySQL identifier then you need to make sure it follows these rules: http://dev.mysql.com...dentifiers.html You also need to make sure they're not entering a username that is already the name of another table in the database. I don't recommend dynamically creating tables for each user. Link to comment Share on other sites More sharing options...
Colourtheory Posted December 19, 2012 Author Share Posted December 19, 2012 How would you reccomend doing it? This is my first time setting up a login/register system and I have no idea how to go about doing it, so I'm being creative. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2012 Share Posted December 19, 2012 Have a table that holds all of your users, 1 record per user. If you have additional objects that are associated with users, have a table to store those also with a field that links them to whatever user they are associated with. If users can upload and "own" files, for example, then you would have a files table that stores the information about each file, with a user ID field that contains the ID of the user who owns that file. Link to comment Share on other sites More sharing options...
Colourtheory Posted December 19, 2012 Author Share Posted December 19, 2012 Ok, I added user ID's. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now