The following function is set up to:
- Collect the
user_idfrom my database, as you can see belowWHERE subscriber = '$user'. And then: - return the possible multiple values that
user_idare.
However, when I’ve tried to use this function, it has only collected an array, with the key 0, and value user_id. For apparent reasons I want the array to contain the numerical value that is in the user_id column in my database with the key user_id.
function get_subscribitions($user)
{
$user = mysql_real_escape_string ($user);
$sql = "SELECT 'user_id' FROM `subscribe` WHERE subscriber = '$user'";
$result = mysql_query($sql);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
mysql_free_result($result);
return $rows;
}
Can anyone please pinpoint where I’m making the error leading to these related problems?
Any help appreciated, thank you in advance!
It should be:
There were unnecessary quotes in the query and you were not reading the $row array properly