Setting up seems simple, but the number of potential causes is overwhelming for someone new to programming like me:
In JavaScript, I define and later call:
function dbUpdate(x, y, z) {
$.ajax({
url: 'php/dbUpdate.php',
type: 'post',
data: {table: x, column: y, value: z},
success: function(html) {
}
});
}
dbUpdate("userbase", "currentLanguage", "en");
In php/dbUpdate.php, this data is received and processed into an UPDATE query, which has worked numerous times:
$userID = 0;
$table = ($_POST['table']);
$column = ($_POST['column']);
$value = ($_POST['value']);
mysql_query("UPDATE $table SET $column=$value WHERE id=$userID", $con);
// assume $con is defined
The issue arises when the 'z' argument in dbUpdate is an integer (e.g., var z = 70;), there are no problems. However, with a simple string (e.g., var z = "en"; as shown above), it fails to update.
I've checked the database's structure, and it's set to 'varchar', so it should be able to accept strings. But who am I to assume I understand everything fully.
I suspect it may be a basic syntax error that a beginner might miss, but I'm tired of endlessly tweaking the syntax without any success, or having it cause issues later on when used differently.
I'm hopeful that you wonderful folks can assist me in resolving this!