I got an database that looks like
COUNTRY RATES
AUD 0.5
BRL 1.2
CAD 1.6
CHF 1.4
CZK 2.5
now i want to update the rates using this array
$rates = array (
'AUD' => '0.5',
'BRL' => '6.2',
'CAD' => '2.6',
'CHF' => '7.4',
'CZK' => '1.5',
);
i tried using this code
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "eurotoforgein";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$table = 'rates';
$values = "'" . implode("','", array_values($rates)) . "'";
$sql = "UPDATE `eurotoforgein` SET 'RATES' WHERE rates = $values";
if(!$result = $conn->query($sql)){
die('There was an error running the query [' . $conn->error . ']');
}
else{
echo "Data Updated.";
}
but i get There was an error running the query [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''RATES' WHERE rates = '0.5','1.2','1.6','1.4','2.5'' at line 1]
any help is welcome