3 Replies - 375 Views - Last Post: 08 February 2012 - 05:24 AM Rate Topic: -----

#1 Jezzabeanz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 19-September 11

SQL query syntax error

Posted 08 February 2012 - 05:01 AM

Hi,

I'm trying convert passwords from a database that weren't originally SHA1 encrypted, so I'm trying to do a simple update however the update isn't successful. After echoing the results of the sql query and pasting it into PHPMyAdmin to see if there are any errors, I appear to have an error in my syntax.

Maybe I just need some fresh eyes onto this.

PHP:
sql = "UPDATE employee SET (First_name='$oldfname', Surname='$oldsname', Email='$oldemail', Password='" . SHA1($oldpword) . "', Type='$oldtype') WHERE EmpID = $oldempid";


Outputted SQL:
UPDATE employee SET (First_name='John', Surname='Doe', Email='jdoe@gmail.com', Password='a0367e1caffa9e4b5d08f9e83a5e63fea9d3978e', Type='Manager') WHERE EmpID = 1


PHPMyAdmin response:
"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(First_name='John', Surname='Doe', Email='jdoe@gmail.com', Password='a0' at line 1"

Thanks,
Jezzabeanz

Is This A Good Question/Topic? 0
  • +

Replies To: SQL query syntax error

#2 KingCuddles  Icon User is offline

  • D.I.C Regular

Reputation: 176
  • View blog
  • Posts: 496
  • Joined: 20-December 08

Re: SQL query syntax error

Posted 08 February 2012 - 05:05 AM

Try,

UPDATE employee SET First_name='$oldfname', Surname='$oldsname', Email='$oldemail', Password='" . SHA1($oldpword) . "', Type='$oldtype' WHERE EmpID = $oldempid


Was This Post Helpful? 2
  • +
  • -

#3 Jezzabeanz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 19-September 11

Re: SQL query syntax error

Posted 08 February 2012 - 05:07 AM

Ah thank you! Such a simple error.

+rep
Was This Post Helpful? 0
  • +
  • -

#4 KingCuddles  Icon User is offline

  • D.I.C Regular

Reputation: 176
  • View blog
  • Posts: 496
  • Joined: 20-December 08

Re: SQL query syntax error

Posted 08 February 2012 - 05:24 AM

No trouble.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1