rule69 Posted May 2, 2008 Share Posted May 2, 2008 <?php $logged = $_GET['ses']; $brws = explode ("(", $_SERVER['HTTP_USER_AGENT']); $rbrws = $brws[0]; $ip = $_SERVER['REMOTE_ADDR']; $sid2 = $_COOKIE['PHPSESSID']; $time = time(); // Clean Broswer white Space $brwser = str_replace(" ", "", $rbrws); //echo $_COOKIE['PHPSESSID']; $sql = "SELECT uname,sid,COUNT(*) FROM `chat` WHERE sid='".$logged."' GROUP BY `time` DESC"; $result = mysql_fetch_row(mysql_query($sql)); list($uname,$sid) = $result; echo " <form action=\"addmsg.php\" method=\"POST\"> <input type=\"hidden\" name=\"brws\" value=\"$brwser\"> <input type=\"hidden\" name=\"ip\" value=\"$ip\">"; if($sid=$logged) { echo " <input type=\"hidden\" name=\"sid\" value=\"$sid\">"; } else { echo " <input type=\"hidden\" name=\"sid\" value=\"$sid2\">"; } echo" <input type=\"hidden\" name=\"time\" value=\"$time\"> "; if($sid=="$logged") { echo "<input type=\"hidden\" name=\"name\" value=\"$uname\">"; } else { echo "Name: <input type=\"text\" name=\"name\"> <br />"; } echo"Message:<br /> <textarea rows=\"2\" cols=\"20\" name=\"msg\"> </textarea> <br /> <input type=\"submit\" value=\"Add\"> </form>"; ?> { Hi this is what im trying to accomplish.. if the session is identical to the one that is fetched from the variable then it must print the hidden form else it must print the input form it works in a way BUT even if the strings dont match it outputs the hidden form . only when the variable is blank does it print the input from.. all help will be appreciated Link to comment https://forums.phpfreaks.com/topic/103885-solved-mysql-result-variable/ Share on other sites More sharing options...
947740 Posted May 2, 2008 Share Posted May 2, 2008 Change: if($sid=$logged) To: if($sid==$logged) Link to comment https://forums.phpfreaks.com/topic/103885-solved-mysql-result-variable/#findComment-531798 Share on other sites More sharing options...
rule69 Posted May 2, 2008 Author Share Posted May 2, 2008 nope not working.. i had this working: <?php $logged = $_GET['ses']; $brws = explode ("(", $_SERVER['HTTP_USER_AGENT']); $rbrws = $brws[0]; $ip = $_SERVER['REMOTE_ADDR']; $sid2 = $_COOKIE['PHPSESSID']; $time = time(); // Clean Broswer white Space $brwser = str_replace(" ", "", $rbrws); //echo $_COOKIE['PHPSESSID']; $sql = "SELECT uname,sid,COUNT(*) FROM `chat` WHERE sid='".$logged."' GROUP BY `time` DESC"; $result = mysql_fetch_row(mysql_query($sql)); list($uname,$sid) = $result; echo " <form action=\"addmsg.php\" method=\"POST\"> <input type=\"hidden\" name=\"brws\" value=\"$brwser\"> <input type=\"hidden\" name=\"ip\" value=\"$ip\">"; if(preg_match("/$sid/", "$logged")) { echo " <input type=\"hidden\" name=\"sid\" value=\"$sid\">"; } else { echo " <input type=\"hidden\" name=\"sid\" value=\"$sid2\">"; } echo" <input type=\"hidden\" name=\"time\" value=\"$time\"> "; if(preg_match("/$sid/", "$logged")) { echo "<input type=\"hidden\" name=\"name\" value=\"$uname\">"; } else { echo "Name: <input type=\"text\" name=\"name\"> <br />"; } echo"Message:<br /> <textarea rows=\"2\" cols=\"20\" name=\"msg\"> </textarea> <br /> <input type=\"submit\" value=\"Add\"> </form>"; ?> then i said lemme try ur code now it done work wth its soo wierd... that worked well but as soon as i tried ur code and then ctrl + z now its broke...maybe im mising somthng again... Link to comment https://forums.phpfreaks.com/topic/103885-solved-mysql-result-variable/#findComment-531805 Share on other sites More sharing options...
947740 Posted May 2, 2008 Share Posted May 2, 2008 Try this (I made the change again for you): <?php $logged = $_GET['ses']; $brws = explode ("(", $_SERVER['HTTP_USER_AGENT']); $rbrws = $brws[0]; $ip = $_SERVER['REMOTE_ADDR']; $sid2 = $_COOKIE['PHPSESSID']; $time = time(); // Clean Broswer white Space $brwser = str_replace(" ", "", $rbrws); //echo $_COOKIE['PHPSESSID']; $sql = "SELECT uname,sid,COUNT(*) FROM `chat` WHERE sid='".$logged."' GROUP BY `time` DESC"; $result = mysql_fetch_row(mysql_query($sql)); list($uname,$sid) = $result; echo " <form action=\"addmsg.php\" method=\"POST\"> <input type=\"hidden\" name=\"brws\" value=\"$brwser\"> <input type=\"hidden\" name=\"ip\" value=\"$ip\">"; if($sid==$logged) { echo " <input type=\"hidden\" name=\"sid\" value=\"$sid\">"; } else { echo " <input type=\"hidden\" name=\"sid\" value=\"$sid2\">"; } echo" <input type=\"hidden\" name=\"time\" value=\"$time\"> "; if($sid=="$logged") { echo "<input type=\"hidden\" name=\"name\" value=\"$uname\">"; } else { echo "Name: <input type=\"text\" name=\"name\"> <br />"; } echo"Message:<br /> <textarea rows=\"2\" cols=\"20\" name=\"msg\"> </textarea> <br /> <input type=\"submit\" value=\"Add\"> </form>"; ?> Link to comment https://forums.phpfreaks.com/topic/103885-solved-mysql-result-variable/#findComment-531808 Share on other sites More sharing options...
rule69 Posted May 2, 2008 Author Share Posted May 2, 2008 thanks that did the trick. .. thanks mate.. Link to comment https://forums.phpfreaks.com/topic/103885-solved-mysql-result-variable/#findComment-531812 Share on other sites More sharing options...
947740 Posted May 2, 2008 Share Posted May 2, 2008 No problem. Link to comment https://forums.phpfreaks.com/topic/103885-solved-mysql-result-variable/#findComment-531821 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.