joomtalk Posted April 27, 2012 Share Posted April 27, 2012 Hi!!! i created this code for my chatroom!! <?php $usern=$_SESSION['etchat_'.$this->_prefix.'username']; $con1 = mysql_connect("localhost","manosir_main","***********"); if (!$con1) { die('Could not connect: ' . mysql_error()); } mysql_select_db("manosir_manoshos_main", $con1); $query = "SELECT etchat_user_online_user_sex AS gender FROM db1_etchat_useronline WHERE etchat_user_online_user_name = '$usern'"; $result= mysql_query($query); $user = mysql_fetch_assoc($result); if($user['gender']=='m'){ ?> <span style=" font-size: 12px; font-family: tahoma; direction: rtl; font-weight: bold; color: #0000FF " > male</span> <?php } if($user['gender']=='f'){ ?> <span style= "font-size: 12px; font-family: tahoma; direction: rtl; font-weight: bold; color: #FF47D1" > female</span><?php } mysql_close($con1); ?> it gets the users`s username when he login from session and get his/her sex by mysql!!!!! the starnge part is this: when i login to page it doesnt work..but when i refresh the page it works :confused: :confused: :confused: in first opening the $usern is empty!! whats wrong!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/ Share on other sites More sharing options...
requinix Posted April 27, 2012 Share Posted April 27, 2012 Does this code execute sometime before the login code? If not then how does this little code snippet work with the rest of the site? Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/#findComment-1341009 Share on other sites More sharing options...
joomtalk Posted April 27, 2012 Author Share Posted April 27, 2012 it works after login!!! when user login and redirected to the chat page!!! this is the page but i suppose u wont understand anything! manos.ir Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/#findComment-1341036 Share on other sites More sharing options...
joomtalk Posted April 28, 2012 Author Share Posted April 28, 2012 any idea???? Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/#findComment-1341356 Share on other sites More sharing options...
requinix Posted April 28, 2012 Share Posted April 28, 2012 So does it work or does it not work? Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/#findComment-1341360 Share on other sites More sharing options...
joomtalk Posted April 28, 2012 Author Share Posted April 28, 2012 it works after a refresh!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/#findComment-1341363 Share on other sites More sharing options...
requinix Posted April 28, 2012 Share Posted April 28, 2012 I can't tell if you answered my earlier question so I'll ask it again: Does this code execute sometime before the login code? If not then how does this little code snippet work with the rest of the site? Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/#findComment-1341373 Share on other sites More sharing options...
jcbones Posted April 28, 2012 Share Posted April 28, 2012 I am with requinix on this one. I think the problem is with code PLACEMENT, but without more than this little snippet we cannot track down what should go where. Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/#findComment-1341391 Share on other sites More sharing options...
joomtalk Posted April 29, 2012 Author Share Posted April 29, 2012 Hi i said!!this code execute after loginpage..inside the chatting page ..... i will try and change the lace and will use it as a function!!!i will say the result!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/261687-strange-problemonly-work-after-a-refresh/#findComment-1341530 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.