A newbie if problem

software development

#1

hi i have a newbie if problem

im doing a social bookmarking script

i have this urls
http://mysite.com/index.php
http://mysite.com/index.php?cat=1
http://mysite.com/index.php?page=1

i made this script (but the else function is not workin)

PHP Code:
if ($_GET[‘page’] == “”) {
$url = urlencode($scripturl . ‘?cat=’ . $_GET[‘cat’]);
}
elseif ($_GET[‘cat’] == “”) {
$url = urlencode($scripturl . ‘?page=’ . $_GET[‘page’]);
}
else {
$url = urlencode($scripturl);
}

it works but when iam in the index.php
it execute this code

PHP Code:
if ($_GET[‘page’] == “”) {
$url = urlencode($scripturl . ‘?cat=’ . $_GET[‘cat’]);
}

i just want to get the $url working
thanks


#2

How about this?

if (isset($_GET[‘page’]) and empty($_GET[‘page’])) {
$url = urlencode($scripturl . ‘?cat=’ . $_GET[‘cat’]);
}
else if (isset($_GET[‘cat’]) and empty($_GET[‘cat’])) {
$url = urlencode($scripturl . ‘?page=’ . $_GET[‘page’]);
}
else {
$url = urlencode($scripturl);
}

Save $97 (MAX Discount) with code: [color=#CC0000]97YES[/color] Sign Up NOW or More Codes Here


#3

If you use empty(), you don’t need to check if a variable is set (empty will return false without error in that case).


Read my blog. You know you want to…