updateSingleCell.php issue
I realize that this may not be the right place for PHP questions, but since many of you may have already implemented a "updateSingleCell.php" or something similar, I thought you may have had a similar issue.
The error I get is always the same:
Where '2' is actually the Contact_ID of the contact in the table (see the code please).
Contact_ID does indeed exist in my table as an int(10). I just don't understand ... the column should be "Contact_ID" per my where clause and the value is "2", not a column named "2" -- what am I missing here?
thanks!
<?php
// Full db user info ...
$hostname_connAdmin = "localhost";
$database_connAdmin = "db";
$username_connAdmin = "db_admin";
$password_connAdmin = "password";
$connAdmin = mysql_pconnect($hostname_connAdmin, $username_connAdmin, $password_connAdmin) or trigger_error(mysql_error(),E_USER_ERROR);
/*
// Data from $_POST ...
$Contact_ID = intval($_POST['Contact_ID']);
$column = $_POST['column'];
$text = $_POST['text'];
*/
// Same data used to troubleshoot, get same error ...
$Contact_ID = 2;
$column = "3";
$text = "Brougham";
$contactFields = array('Contact_ID','Title','First_Name','Middle_Name','Last_Name','Suffix','Friend_Of','Street','City','State','Zip','Phone','Email');
$columnName = $contactFields[$column];
// Set up query ...
$updateSQL = "UPDATE contacts_jmsavoy SET `$columnName`=`$text` WHERE Contact_ID=`$Contact_ID`";
// Run query ...
mysql_select_db($database_connAdmin, $connAdmin);
$Result1 = mysql_query($updateSQL, $connAdmin) or die(mysql_error());
?>
The error I get is always the same:
Unknown column '2' in 'where clause'
Where '2' is actually the Contact_ID of the contact in the table (see the code please).
Contact_ID does indeed exist in my table as an int(10). I just don't understand ... the column should be "Contact_ID" per my where clause and the value is "2", not a column named "2" -- what am I missing here?
thanks!
Jeremy Savoy
January 21,