Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unknown column in 'field list'

Status
Not open for further replies.

ArmenD

Programmer
Feb 3, 2005
101
US
hi all,
i am creating a simple registration page in php/mysql but have a ?.


the db is fine but i am getting this error and i don't know why...

Unknown column 'password' in 'field list'

*******************************register.php
<html>
<head>
<title>Register</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?

@mysql_connect("localhost", "l", "9") or die("Cannot connect to DB!");
@mysql_select_db("db1") or die("Cannot select DB!");
$sql="INSERT INTO userlist ( u_password ,u_username ) VALUES (".$password.",".$email." ) ";
$r = mysql_query($sql);
if(!$r) {
$err=mysql_error();
print $err;
exit();
}
?>
</body>
</html>
 
The variable $Password does not exist! You need to reference the variable as $_POST['Password'] for the password field for instance. Bit of a pain in the ass and caused me some problems when I started developing in PHP from other languages. Also you have a full stop in front of the field (.$password) that I don't think you need!

Hope this helps!

Tony
 

change the double quotes for single quotes INSIDE the values statement of the sql clause and delete the "." concatenation operators.

if you want to keep the concats then insert single quotes before and after the doule quotes.

yous should also escape the vars before inserting them

Code:
$password = mysql_escape_string($password);
$email = mysql_escape_string($email);
$sql="INSERT INTO  userlist (u_password ,u_username  ) VALUES ('$password','$email') ";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top