1

the query is

$sql = "update students set status = 'active', student_password='{$password}' where student_id ='".$_GET['id']."'";

it showing the result as

update students set status = 'active', student_password='50d0d53f546b7' where student_id ='112s23dd'

the error comes

Unknown column '112s23dd' in 'where clause'

when i put any int value in the where clause it works fine but not working in the charecter the student_id is primary key varchar(30)
one more strange thing this is working on phpmyadmin when i paste it there but not work when i execute this on webpage

10
  • Hai Hai, can you display desc students because that's not normal...Try with "status" Commented Dec 18, 2012 at 20:55
  • @jcho360 what do u mean? Commented Dec 18, 2012 at 20:58
  • Are you using a database querying library or just mysql_query()? Commented Dec 18, 2012 at 20:59
  • I think status it's a reserved work, so try to use "`" around status Commented Dec 18, 2012 at 20:59
  • @alex this is simple mysql_query(); Commented Dec 18, 2012 at 21:03

3 Answers 3

1

I have made a fiddle with the data that you have provided. Your query works just fine. I think the problem might be if you have not updated the database on the website or changed the type of column 'student_id' in the meantime. Please double check your database on the server.

Sign up to request clarification or add additional context in comments.

Comments

1

It looks like you have found a Bug:

http://www.sqlfiddle.com/#!2/56e3e/1

provide us the version of your Mysql also if you can try to run the code directly into PHPMyAdmin just to tested it would be better.

Comments

0

Try this:

    mysql_query("update `students` set `status`='active', `student_password`='{$password}' where `student_id`='" . mysql_real_escape_string($_GET['id']) . "'") or die(mysql_error());

By using that, you'll be given a reason for this query not executing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.