Mythical Posted February 10, 2010 Share Posted February 10, 2010 Hello there, i'm trying to create a login/register script for my sim game, but i'm having a little trouble in doing so. Everytime I attempt to test out my registration system, it fails, and I get this message: Error: Unknown column 'username' in 'field list' I've been led to believe that the problem is within my register script, here: $newPlayer = @mysql_query("INSERT INTO players (`username`, `password`, `registered`) VALUES ('$uname', '$pass', '$date')") or die("Error: ".mysql_error()); Can anybody help me with this? i'm very new to php and a little confused. In case you are wondering, I do have a mysql database set up, and there is a column named 'username varchar 150' Sincerely, Mythical. (Attached is the entire document, if you're curious ^^) [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
fesan Posted February 10, 2010 Share Posted February 10, 2010 The error simply means that mysql could not find the column in your table. Double check your spelling and that you are checking / connecting to the right table. Quote Link to comment Share on other sites More sharing options...
sader Posted February 10, 2010 Share Posted February 10, 2010 it canot be column named username if mysql says that it doesn exists. maybe its user_name or uname ? maybe u traveled to another database or another host? what about trying this //connection $query = mysql_query( "SELECT * FROM players" ); $columns = mysql_num_fields($query); for($i = 0; $i < $columns; $i++) { print mysql_field_name($columns,$i)."<br />"; } Quote Link to comment Share on other sites More sharing options...
Mythical Posted February 10, 2010 Author Share Posted February 10, 2010 I double checked all the spellings, and they are correct =] Quote Link to comment Share on other sites More sharing options...
Mythical Posted February 11, 2010 Author Share Posted February 11, 2010 Anybody else??? Quote Link to comment Share on other sites More sharing options...
Mythical Posted February 11, 2010 Author Share Posted February 11, 2010 Any help will be greatly appreciated D= Quote Link to comment Share on other sites More sharing options...
greatstar00 Posted February 11, 2010 Share Posted February 11, 2010 so, show us the screen shot of your database, that would help us or the creation query it must be column spelled incorrectly, that is wat the query error message means Quote Link to comment Share on other sites More sharing options...
Mythical Posted February 11, 2010 Author Share Posted February 11, 2010 Okay, i'll get a screenie in one second :3 Quote Link to comment Share on other sites More sharing options...
Mythical Posted February 11, 2010 Author Share Posted February 11, 2010 Here is the screenie of my database: http://i48.tinypic.com/110htz9.jpg Quote Link to comment Share on other sites More sharing options...
sader Posted February 11, 2010 Share Posted February 11, 2010 yep.. I didi think that maybe u have col names called "name varchar 100" but that was like impossible anyways in the colum Field write name of the table field such id,username,userpass,title,post... no extra stuf like varchar 100, int 10 u set field types (integer,double float, char,text, varchar) on "Type" and u set how length of the field in () Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 11, 2010 Share Posted February 11, 2010 yes exactly As sader just said, your field names have a space and a type as part of the field name. Also all your fields are actually of type int which means they can store only numbers It is a bad idea to have spaces in field names and field names should certainly not contain the type declaration Quote Link to comment Share on other sites More sharing options...
Mythical Posted February 11, 2010 Author Share Posted February 11, 2010 Okay, someone told me differently, thanks =D Quote Link to comment Share on other sites More sharing options...
greatstar00 Posted February 11, 2010 Share Posted February 11, 2010 so, next time, when u tried to create a table, with your own query remember to use those comma correctly or use phpmyadmin's help Quote Link to comment Share on other sites More sharing options...
Mythical Posted February 11, 2010 Author Share Posted February 11, 2010 You have just made me one very happy coder, thanks guys ^^ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.