PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
This piece of code works perfect if the user has a $id listed in DB and is returned from the SQL Query that collects the need values, which first follws this piece of code.
However, if the user does not have a $id in that table, it should do the else if, but it goes straight to the last else.
What should the else if($id == ' ') or else if(empty($id == ' '))??
PLEASE HELP..
Last edited by califdon on Thu Apr 07, 2011 11:50 pm, edited 1 time in total.
Reason:Moderator changed [code] tags to [syntax=php] tags for easier reading.
Your else if($id == ' ') condition is apparently not being met. That's not surprising, since it would be quite odd if the $id value was a space character. You probably mean either a Null value or a zero-length string. These are all seen as different values by PHP. The easy solution is to use the PHP function empty(), which tests for ANY of these conditions: a numeric value of 0, a zero-length string, OR a Null.
if ($id) {
if ($user->get('id') == 0 || $userid == 0 || $userid <> $user->get('id')){
//$url = JURI::root() . 'index.php?' . $component . '&id=' . $id . '&tmpl=component&print=1';
$url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1';
for($i=1;$i<count($type);$i++){
$url.='&'.$type[$i].'='.$layout[$i];
}
}
/*MG made this change here to get the user to got ot set Default Account if they have not one yet. Account Album ID = 27. CaribbeanHeat.tv Main Account.Yah. Mg all the way baby. 042776*/
} else if(empty($id)){
$url=JURI::root().'index.php?option=com_muscol&view=album&id=27&tmpl=component&print=1';
for($i=1;$i<count($type);$i++){
$url.='&'.$type[$i].'='.$layout[$i];
}
} else {
echo 'User Album Loading...';
}