I defined PHP variable $id with a value that is the current Facebook user's ID, extracted from an array returned from a Facebook API call.
$id = $userInfo[id];
I'm confident that the variable is declared correctly because I can echo it's value and have successfully stored the correct value in a database.
I'm trying unsuccessfully to use it in the where clause of a mysql query to return records from the database table the ID and other data is stored in. The query returns the expected results until I add the where clause so I think it's my syntax pertaining to $id. The column I'm filtering by is also named id. None of the syntax I've tried has worked, including the following:
WHERE id = $id
WHERE id = '$id'
WHERE id = "$id"
I've spent the last few days searching for a solution and tried every combination of single quotes, double quotes, and decimals I've seen suggested anywhere.
Edit (Code taken from comments made by author)
mysql_select_db($database_YOUR_giftbox, $YOUR_giftbox);
$query_user_data = "SELECT date, event FROM events WHERE id = $id ORDER BY date ASC";
$user_data = mysql_query($query_user_data, $YOUR_giftbox) or die(mysql_error());
$row_user_data = mysql_fetch_assoc($user_data);
$totalRows_user_data = mysql_num_rows($user_data);
$id = $userInfo[id];is a bit risky: you should use$id = $userInfo["id"];instead.idin the database?