djtozz Posted October 20, 2009 Share Posted October 20, 2009 Hello, I've got following code: if(strpos($row[13],"http://")!==false) $info['results'][$num]['player']="PREVIEW"; else $info['results'][$num]['player']="NO PREVIEW"; and would like to add following AND statement AND ($media=="mp3") Can someone advice me how to do please? I'm getting following error: "unexpected T_LOGICAL_AND" in my code below. if(strpos($row[13],"http://")!==false) AND ($media=="mp3") $info['results'][$num]['player']="PREVIEW"; else $info['results'][$num]['player']="NO PREVIEW"; Thank you Quote Link to comment https://forums.phpfreaks.com/topic/178326-solved-simple-and-question/ Share on other sites More sharing options...
Mchl Posted October 20, 2009 Share Posted October 20, 2009 Add parentheses () around the whole condition. if((strpos($row[13],"http://")!==false) &&($media=="mp3")) { $info['results'][$num]['player']="PREVIEW"; } else { $info['results'][$num]['player']="NO PREVIEW"; } Quote Link to comment https://forums.phpfreaks.com/topic/178326-solved-simple-and-question/#findComment-940290 Share on other sites More sharing options...
djtozz Posted October 20, 2009 Author Share Posted October 20, 2009 Add parentheses () around the whole condition. Thank you! That did the job! Quote Link to comment https://forums.phpfreaks.com/topic/178326-solved-simple-and-question/#findComment-940302 Share on other sites More sharing options...
Daniel0 Posted October 20, 2009 Share Posted October 20, 2009 This essentially comes down to operator precedence, which you might want to learn. Also note that and takes lower precedence than &&. Quote Link to comment https://forums.phpfreaks.com/topic/178326-solved-simple-and-question/#findComment-940318 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.