UPDATE `users` SET `avatar`= $dd WHERE (`users`.`login` $_COOKIE['login']) 

When performing writes

 Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/u565555448/public_html/upload.php on line 17 

And on $ _COOKIE ['login'] does not complain, everything works fine if the place $ dd is substituted with some value. I tried to write $ dd in different ways. And in quotes, and divided the request into three parts, the second of which was $ dd

 "UPDATE `users` SET `avatar`= ".$dd." WHERE (`users`.`login` $_COOKIE['login'])" 

Does not work

  • concatenation you did not put `login` . $_COOKIE['login'] `login` . $_COOKIE['login'] ...... or equal .......... most likely you would like to write so WHERE users.`login` = "$_COOKIE['login']" ... ...... total query "UPDATE `users` SET `avatar`= ".$dd." WHERE `login` ='". $_COOKIE['login']."'" "UPDATE `users` SET `avatar`= ".$dd." WHERE `login` ='". $_COOKIE['login']."'" ........ or "UPDATE `users` SET `avatar`= $dd WHERE `login` = {$_COOKIE['login']}" - Alexey Shimansky
  • @ Alexey Shimansky In the second version, writes the Unknown column 'Morkoffka' in 'where clause' , although in the database the value is hkar.ru/OHnl - Morkoffka
  • Unknown column 'Morkoffka' means that there is no such column , not a value .. that is, you write like WHERE $_COOKIE['login'] = .... - Alexey Shimansky
  • @ Alexey Shimansky, I don’t think my eyes fail , but hkar.ru/OHof is written - Morkoffka
  • It seems that braces should be surrounded by single quotes, making it clear that this (the inserted and compared value) is a string ..... - Alexey Shimansky

1 answer 1

This is how it should work:

 "UPDATE users SET avatar = '".$dd."' WHERE login = '".$_COOKIE['login']."'" 
  • the same song Unknown column 'Morkoffka' in 'where clause' - Morkoffka
  • "UPDATE users SET avatar = '".$dd."' WHERE login = '".$_COOKIE['login']."'" - Kernel Panic