-1

I am running this query to update a password field on user with email x@mail.com and want to update his password, but I am having error. The mysql query:

UPDATE users
SET password=myword
WHERE email=x@mail.com;

The password field is an md5 encrypted field.

The error I got is

#1054 - Unknown column 'myword' in 'field list'

This is my table structure: the mysql table structure

I tried to put the values in "" and '' as well as `` but still the error occurs.

  • No @David because I used quotes when above syntax did not work. Please check the error I provided. I appreciate your time anyways. – Bigg Danta Feb 15 '23 at 13:12
  • The code shown in the question is (was) using double-quotes, which is incorrect. Now the code shown is using no quotes, which is also incorrect. String literals in SQL are single-quoted. You may indeed be *claiming* that you've tried that, but the ongoing edits to the question do not demonstrate this. Can you provide a [mcve] which demonstrates the problem? – David Feb 15 '23 at 13:15
  • Firstly I tried everything without quoting, then single quoting, then double quoting. Anyways, thanks, and I am getting the code to sql fiddle and will share a link here. Sorry for troubling you, @David, I would get back here soon. Thanks for being there. – Bigg Danta Feb 15 '23 at 13:17
  • 1
    FYI: `md5` (and other hashing methods like `sha1`, etc...) are not suited to store passwords. – DarkBee Feb 15 '23 at 13:24

1 Answers1

0

You must use single quotes for string values.

UPDATE users
SET password='myword'
WHERE email='x@mail.com';

Double quotes are used for quoting table and column names with special characters and the like.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
  • But it doesn't solve the error. Phpmyadmin still throwing same error. I tried quotes when nothing worked. However I appreciate your answer, but the above solution isnt executing in phpmyadmin. – Bigg Danta Feb 15 '23 at 13:11
  • 2
    It works just fine for me: https://www.db-fiddle.com/f/gMyuyauYZJmm83oFBYWKr2/0 – Jens Schauder Feb 15 '23 at 13:26