-3

my code are not working, maybe because of the where statement. please help me with what is wrong with this line of code.

query:

mysql_query("UPDATE tblceas_vote SET fldpassword= $three WHERE fldstudno =$login");
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56
user2852776
  • 63
  • 1
  • 5
  • Are you sure about the values if the variables? They're not possibly empty? – JAL Oct 10 '13 at 20:53
  • By the way, learn about [SQL injections](http://en.wikipedia.org/wiki/SQL_injection) and password hashing (e.g. bcrypt). – luiscubal Oct 10 '13 at 21:25

3 Answers3

2

Quotes will probably help:

mysql_query("UPDATE tblceas_vote SET fldpassword= '$three' WHERE fldstudno ='$login'");

Otherwise the proper way is to use escaping: http://php.net/manual/en/function.mysql-real-escape-string.php

Lajos Veres
  • 13,595
  • 7
  • 43
  • 56
0

Put single quotes or escape the string:

mysql_query("UPDATE tblceas_vote SET fldpassword='$three' WHERE fldstudno='$login'");

Or

mysql_query("UPDATE tblceas_vote SET fldpassword='".$three."' WHERE fldstudno='".$login."'");

Also note that MYSQL is deprecated and you should use MySQLi or PDO instead.

Sterling Archer
  • 22,070
  • 18
  • 81
  • 118
0

I agree. Quote are definitely required for text within queries. Also I would suggest you "escape" you content (have a look at mysqli_real_escape_string).

If you ever encounter a "quote" inside your string, it will break your query, unless you escape it.