Jump to content

[SOLVED] if (isset($_GET[... not working properly


acctman

Recommended Posts

can someone help me with the if (isset($_GET statement below where I echo $type; when I first echo the it shows imgPvt which is correct but after I do a check to see if "sec" is 2 or 3 its changing the $type to imgPub when its actually imgPvt. Why is it changing the $type when I'm just checking to see if there is a 2 or 3 value?

 

the sending url looks like this /files/pvtexp.php?mid=<%mm_id%>&iid=$row[i_id]&idat=$en[m_uimg]&sec=1

 

<?php
session_start();
$userid = $_SESSION['userid'];

if($userid == '') {
header("Location: http://www..com");
exit;
}

ob_start(); //hold output
require_once '../password.php';

if (isset($_GET['mid']) && isset($_GET['iid']) && isset($_GET['idat'])) {

$mid = $_GET['mid'];
$iid = $_GET['iid'];
$date = $_GET['idat'];

	if (isset($_GET['sec']) == '1') { $type = "imgPvt";
	$allowed = 0;
		if (isset($_SESSION['userid']) && $_SESSION['userid'] > 0) {
			$sql = "select p_id from rate_private where p_from='$mid' and p_to='" .$_SESSION['userid']. "'";
			$result = mysql_query($sql);
			if (mysql_num_rows($result) > 0 || $mid == $_SESSION['userid'] || $_SESSION['userid'] == '39') {
			$allowed = 1;
			} elseif ($allowed == 0 && isset($_GET['sec']) == 1) {
				header("Location: http://www..com");
				exit;
				}
			} 
	} 
echo $type;	//at this point its saying imgPvt	
	if (isset($_GET['sec']) == '2') { $type = "imgExp"; } 
	if (isset($_GET['sec']) == '3') { $type = "imgPub";	}
echo $type;	//now its telling me imgPub 	
			header("Content-type: image/jpeg");
			if (isset($_GET['tmb']) == 1) {
			$im = imagecreatefromjpeg('/'.$date.'/'.$mid.'/'.$type.'/imgTmb/'.$mid.'-'.$iid.'.jpg');
				} else {
			$im = imagecreatefromjpeg('/'.$date.'/'.$mid.'/'.$type.'/'.$mid.'-'.$iid.'.jpg');		
			}
			imagejpeg($im); 
			imagedestroy($im);				
}

$buf = ob_get_contents();
ob_end_clean();
print $buf;

?>

Link to comment
Share on other sites

if (isset($_GET['sec']) == '2') { $type = "imgExp"; }

if (isset($_GET['sec']) == '3') { $type = "imgPub"; }

 

isset only can only == 1 or 0, not 2 and 3.

 

isset only checks if $_GET has a value set, not what that value actually is.

 

You should have it as

 

if ($_GET['sec'] == '2') { $type = "imgExp"; }

if ($_GET['sec'] == '3') { $type = "imgPub"; }

 

and the same for the one further up.

Link to comment
Share on other sites

if (isset($_GET['sec']) == '2') { $type = "imgExp"; }

if (isset($_GET['sec']) == '3') { $type = "imgPub"; }

 

isset only can only == 1 or 0, not 2 and 3.

 

isset only checks if $_GET has a value set, not what that value actually is.

 

You should have it as

 

if ($_GET['sec'] == '2') { $type = "imgExp"; }

if ($_GET['sec'] == '3') { $type = "imgPub"; }

 

and the same for the one further up.

 

i spent 2hrs trying to figure out if it was a cache or buffer causing the problem.

thanks for fixing my error

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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