Topic: mysql problem...

The following bit of PHP gives me the MySQL error: #1054 - Unknown column 'jer' in 'where clause'

$result = mysql_query("SELECT `id` FROM `members` WHERE `username` = ".$post['username']." AND `password` = ".$post['password']."", $open) or die(mysql_error());

The above line is in a function so $post is correct and the value of $post['username'] is currently 'jer'

Any help?

Re: mysql problem...

messy code... get rid of all unnecessary quotes:

$result=mysql_query("SELECT id FROM members WHERE username=$post['username']")

also, hash the password using for instance md5.

PS:use the "code" BBcode tag

Re: mysql problem...

you want "username='$post['username']'" (with the ' around the value). Same for password.

Re: mysql problem...

pedrotuga wrote:

messy code... get rid of all unnecessary quotes:

$result=mysql_query("SELECT id FROM members WHERE username=$post['username']")

also, hash the password using for instance md5.

PS:use the "code" BBcode tag

Won't work.

$result = mysql_query("SELECT `id` FROM `members` WHERE `username` = '".mysql_real_escape_string($post['username'])."' AND `password` = '".mysql_real_escape_string($post['password'])."'", $open) or die(mysql_error());

Re: mysql problem...

Thanks for the help and the tips!