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] Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/ 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. Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010364 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 />"; } Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010367 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 =] Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010375 Share on other sites More sharing options...
Mythical Posted February 11, 2010 Author Share Posted February 11, 2010 Anybody else??? Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010860 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= Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010884 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 Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010889 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 Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010891 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 Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010901 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 () Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010911 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 Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010917 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 Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010918 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 Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010920 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 ^^ Link to comment https://forums.phpfreaks.com/topic/191681-field-list-error/#findComment-1010925 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.