Okay, I'm really stuck here. I'm trying to make it so that when users click on a date on a calendar (which is working perfectly), it will add their id (established upon site registration) into a table called "Availability" under the date for which they clicked.
Example: User #17 clicks on March 20th on the calendar. This script should then save the value '17' into the table in the column '3-20' (for march 20th), in the row where the id matches their id.
As you can see in the script, I have stored the month and day as session variables in the calendar script. I am then combining these into one variable "$availdate". That variable is then getting used to find the matching column in the table.
The script is giving me the following error:
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '3-29 ='17' WHERE id ='17'' at line 2"
Thank you in advance for any help!
<?
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
$username = $_SESSION['username'];
$referee_name = $_SESSION['referee_name'];
# to avoid conflict with the session
$refid = $_SESSION['id'];
// Register session key with the value
$_SESSION['day'] = $day;
$_SESSION['month'] = $month;
$availdate = "$month-$day";
//check for validity of user
//set up table and database names
$db_name ="refphoto_testdb";
$table_name ="availability";
//connect to server and select database
$connection = @mysql_connect("localhost","refphoto","08291983") or die(mysql_error());
$db = @mysql_select_db($db_name,$connection) or die(mysql_error());
//build and issue query
$sql ="UPDATE $table_name SET
".$availdate." ='$refid'
WHERE id ='$_SESSION[id]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
?>