I’m stuck on a simple MYSQL UPDATE statement; selecting an ID from the database, and then updating a record WHERE ID = $ID. Code:
$searchDates = ('SELECT * FROM booking_event WHERE subject != "Closed" AND is_reminded IS NULL AND DATE_ADD(NOW(), INTERVAL 2 DAY) >= `starting_date_time` AND NOW() <= `starting_date_time`');
$result = mysql_query($searchDates) or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
$id = $row['event_id'];
mysql_query("UPDATE booking_event SET is_reminded = 1 WHERE event_id = '$id'") or die (mysql_error());
}
For some reason it won’t update with the ID selected from the database – I’ve tried using a testID variable and it works fine.
Any help would be appreciated
Thanks!
PHP variables are case sensitive. Most likely your column name in MYSQL will be something like
Event_Idor any other casing. UsingSELECT *will return the actual name, so to fetch it you would need$id = $row['Event_Id'];Best thing to be sure you dont have a casing problem, use:
and then
$id = $row['event_id'];will work.