-2
$a_sql=mysql_query("UPDATE farmer 
INNER JOIN log_farmer 
ON (farmer.User = log_farmer.User) 
SET farmer.User = "$Username", 
    log_farmer.User="$Username", 
    log_farmer.Pass ="$Password" 
WHERE farmer.User="$Username" 
and log_farmer.User="$Username"");
Sloan Thrasher
  • 4,953
  • 3
  • 22
  • 40
  • Welcome to Stack Overflow. Please edit this question to include what the error is, what you have tried to fix it, and also please use the code formatting button to format the example code correctly. – Bassinator Dec 10 '17 at 19:04
  • Notice how the syntax highlighting shows where the errors are for this particular issue. At least, when you format it as code. – Sloan Thrasher Dec 10 '17 at 19:06
  • **Danger**: You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) that has been [removed](http://php.net/manual/en/mysql.php) from PHP. You should select a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). – Quentin Dec 10 '17 at 19:18

2 Answers2

0

You need to use single quotes inside double quotes, or escape the inners one.

$a_sql=mysql_query("UPDATE farmer INNER JOIN log_farmer ON (farmer.User=log_farmer.User) SET farmer.User='$Username', log_farmer.User='$Username', log_farmer.Pass ='$Password' WHERE farmer.User='$Username' and log_farmer.User='$Username'");

Or

$a_sql=mysql_query("UPDATE farmer INNER JOIN log_farmer ON (farmer.User=log_farmer.User) SET farmer.User=\"$Username\", log_farmer.User=\"$Username\", log_farmer.Pass =\"$Password\" WHERE farmer.User=\"$Username\" and log_farmer.User=\"$Username\"");


Your code is SQL injection vulnerable and you store the passwords in plaintext!

pavel
  • 26,538
  • 10
  • 45
  • 61
0

You need to use proper quoting:

$a_sql=mysql_query("UPDATE farmer 
INNER JOIN log_farmer 
ON (farmer.User = log_farmer.User) 
SET farmer.User = '$Username', 
    log_farmer.User='$Username', 
    log_farmer.Pass ='$Password' 
WHERE farmer.User='$Username' 
and log_farmer.User='$Username'");

More importantly, you need to use the mysqli_ functions instead of mysql_. The later are depreciated, and not supported in current versions of PHP. Also, your code is susceptible to SQL Injection. Use parameterized queries instead.

Sloan Thrasher
  • 4,953
  • 3
  • 22
  • 40