Jump to content

[SOLVED] Mysql Result = $variable ??


rule69

Recommended Posts

<?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

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...

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>";

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.