Hey, just signed up to this forum so first of all would like to say Hi . I am currently working on a review website building from code I had written previously. The problem I am having is with my login script. I Have three pages set out index.html, login.html and loginCentre.html. The login previously worked on my old site however I changed the email login field to username( thought it looked more professional :)). I also changed the names of fields in mySQL database. I used a nice bit of code to echo out the query and got the error message on my login.html file :

There is something wrong with my query ! executed query = SELECT id,name,password FROM customers where username='asd' Error =Unknown column 'username' in 'where clause'

The query I was trying to run was:

$dbQuery="SELECT id,name,password FROM customers where username='$username'";
$result = mysql_query($dbQuery,$db)

Any input would be much appreciated.

Thanks in advance guys :)

I have since changed the field name in the table to login as well as with the forms which is no longer giving me the error message however it is not storing the username as session variable like it should be. Any help please?


The only reason that it would give the "unknown column" error is if the column does not exist or there was a misspelling of the name that causes a mismatch,
The $username might not be parsed as a variable because it is is enclosed in single quotes. The overall double quotes will parse the $ as a special character.

Ok, well no problem with the variable. You have double-quotes around the string which is fine.
The problem is that it can't find the "username" field in your database table. Either you're loading the wrong table, or the field name is incorrect. Just double-check the spelling of the field in the database and script.

Thanks guys just renamed the field name in the script and database

Thanks guys just renamed the field name in the script and database

Problem solved! please mark the thread as such.

scroll down to the bottom and you will see "mark as solved. I think you might have to hit quick reply to see it.