PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I know, I know this problem is EVERYWHERE but i just dont understand! I have a solid knowlage of php but my SQL skills are low, so i dont know too much about Keys and stuff. But my error is: Duplicate entry '' for key 2.
mysql_query("INSERT INTO users (uid) VALUES ($uid)")
So its telling me tht the uid exists is it not? When in the database its not there, however i think the cause to my problem is in the database there is a "0" (zero) in the columb so maybe because of the zero's its saying something is there? I dont know I would appriciate any help
How are you getting uid? It sounds like uid is a unique primary key and you are trying to create a new row in the database with a uid of 2 when you already have one in there.
shawngoldw wrote:How are you getting uid? It sounds like uid is a unique primary key and you are trying to create a new row in the database with a uid of 2 when you already have one in there.
Shawn
Hey,
Sorry i should have said before this gets someones facebook info and loggs them in (facebook connect) and uid is a uniquie id from a facebook account that lets me id them. So here is where i call on the uid:
For example my uid is (just made this up) 655238384 then it puts it into the database (which it isnt). When i manually insert the uid it runs the ELSE part of my if:
Then here you are trying to insert that same uid back into the users table, but it already exists there because you just selected it from there. Why???
mysql_query("INSERT INTO users (uid) VALUES ($uid)");
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Then here you are trying to insert that same uid back into the users table, but it already exists there because you just selected it from there. Why???
Hmm, when i delete all rows from the database then it adds the uid to it, but after that the error returnes. I want to say something logical, but i cant think of anything :/
shawngoldw wrote:By if the "id is correct", what exactly do you mean. How do you define correct?
You're saying that it works for you but not other people???
Shawn
Hey Shawn,
by correct i mean the uid is in the database so the num_rows would return 1 as its there. And it works for me and one other person out of about 5 so far.