Jump to content

DBUnknown column 'pass1' in 'field list'


ferd

Recommended Posts

Hello,

 

Sorry, but after a while of searching for my subject, it doesn't appear  that anyone else has had these particular set circumstances surrounding the error below.

If someone could be so kind as to look at the following code and maybe tell me what I'm doing wrong.

 

$user = $_POST['User'];
$pass = $_POST['Password'];

mysql_query("INSERT INTO users (name, passwd) VALUES('$user', ENCRYPT($pass,concat(\"\$1\$\",right(md5(rand()),,\"\$\"))) ") or die('DB' .mysql_error());

That query returns the following error:

DBUnknown column 'pass1' in 'field list'

 

Where pass1 is my posted password. I know it's the ENCRYPT() function, but for the life of me I can't figure out what exactly is wrong with it. The query works fine if I substitute ENCRYPT(...) with '$pass', and it also works ok using ENCRYPT()if the password happens to be all numbers. I tried different ways of using quotes but that didn't worked either.

 

Thanks in advance for any help.

 

Link to comment
https://forums.phpfreaks.com/topic/199727-dbunknown-column-pass1-in-field-list/
Share on other sites

The value you are entering is a string, all strings handled within an MySQL query have to be delimited by quotes so that the MySQL engine can distinguish it from key works.

 

mysql_query("INSERT INTO users (name, passwd) VALUES('$user', ENCRYPT('$pass',concat(\"\$1\$\",right(md5(rand()),,\"\$\"))) ") or die('DB' .mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.