Can't get php update to work for mysql
First, I am a beginner with php and mysql. I'm testing out a script to update the value in a column. This script keeps throwing the error "Query was empty". I'm trying to put the $activationNumber value into a column called activation1 for the row where the value in the serial column matches the $serialNumber value.
I double checked and there is a row in the table with the $serialNumber value in the serial column. There is also a column called activation1.
Code:
<?php
$serialNumber = 'TEST-1234-TEST-6789';
$activationNumber = 'TEST123';
$con = mysql_connect("localhost","unsername","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$query = "UPDATE my_table SET activation1 = '$activationNumber', WHERE serial = '$serialNumber'";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Activation Added to Database";
mysql_close($con);
?>