eldan88 Posted April 7, 2013 Share Posted April 7, 2013 Hey, I am trying to see if the current store_name session is equal to any of the session name I have assigned into the $store_array but I don't seem to be getting any luck. Below is my code. Any suggestions? $store_array = array('store1', 'store2'); function chain_report(){ global $store_array; if($_SESSION["store_name"] == $store_array) { Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted April 7, 2013 Share Posted April 7, 2013 try either in_array OR array_key_exists Quote Link to comment Share on other sites More sharing options...
eldan88 Posted April 7, 2013 Author Share Posted April 7, 2013 Thanks for the post. I have tried the in_array function below $store_array = array("store1","store1"); function chain_report(){ global $store_array; if(in_array($_SESSION["store_name"],$store_array)) { I got the following error message..Parse error: syntax error, unexpected T_IF, expecting ',' or ';' What does that mean? try either in_array OR array_key_exists Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted April 7, 2013 Share Posted April 7, 2013 That error doesn't reference those lines, it's most likely somewhere else in the function. Post all of the code. Quote Link to comment Share on other sites More sharing options...
eldan88 Posted April 11, 2013 Author Share Posted April 11, 2013 That error doesn't reference those lines, it's most likely somewhere else in the function. Post all of the code. Hey Paul, I rewrote the function and this time its not showin that same error message, its just not showing anything. Below is my functon I wrote $store_array = array('demo', 'giorgios'); function chain_report2($store_session) { global $store_array; if(in_array($store_session,$store_array)){ $output = "Demo 1"; } return $output; } Below is how I called the function chain_report2($_SESSION["store_name"]); Its not reurning the string "Demo 1" on neither sessions. Please help.. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted April 11, 2013 Share Posted April 11, 2013 <?PHP $store_array = array('demo', 'giorgios'); function chain_report2($store_session) { $output = ''; global $store_array; if(in_array($store_session,$store_array)){ $output .= "Demo 1"; } return $output; } echo chain_report2($_SESSION['store_name']); ?> You actually have to echo out the returned data for it to show. Quote Link to comment Share on other sites More sharing options...
Solution eldan88 Posted April 11, 2013 Author Solution Share Posted April 11, 2013 <?PHP $store_array = array('demo', 'giorgios'); function chain_report2($store_session) { $output = ''; global $store_array; if(in_array($store_session,$store_array)){ $output .= "Demo 1"; } return $output; } echo chain_report2($_SESSION['store_name']); ?> You actually have to echo out the returned data for it to show. Wow you are right!!!!! Thank you so much for your help! :happy-04: Quote Link to comment 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.