Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies


11:25 pm on Aug 31, 2002 (gmt 0)

10+ Year Member

Hi all,
I'm having a bit of trouble with a piece of code here. First, the code ...

class menu {
var $menu_request = "";
var $page_link = "";
function menu() {
$this->menu_request = $_GET['type'];
$request = $this->menu_request;
if (! empty($request)) {
$sql = "select * from page_name where pname='".$request."'";
$result = dbQuery($sql);
$result = dbResult($result,0,"pname");
if ($request == $result ) {
$result = dbQuery($sql);
$result = dbResult($result,0,"page");
$this->page_link = $result;

Now the problem, I am having trouble with $_GET['type'] when I first access the page. The reason is because the url is www.mysite.com/index.php does not have the ?type= at the end of it. Now once I click on a link, it gives type a value and the error goes away. What I wanted to know is if anyone knows of a way to tell the script that if the URL string does not have a ?type=string at the end of it to not use $_GET['type']?

Now let me tell you that everytime that I put $_GET['type'] anywhere in the script, no matter if it's in a variable, if it does not have a value, it will give me the error.


11:36 pm on Aug 31, 2002 (gmt 0)

10+ Year Member

Nevermind just fixed the problem.

I just added this code

$string = $_SERVER['QUERY_STRING'];
if (empty($string)) {
$this->menu_request = "home";
} else
$this->menu_request = $_GET['type'];

Sorry for the bother

11:47 pm on Aug 31, 2002 (gmt 0)

10+ Year Member

And if i go to your page as: [yoursite.tld...] you will still get that error...

isset -- Determine whether a variable is set


returns true if the variable you're asking about is set.

Also, (and i'm just seeing this) it can test for several variables at once! (Looks like it's exclusive, every $var has to be set for it to return true.)

12:19 am on Sep 1, 2002 (gmt 0)

10+ Year Member

actually slade it's working good the I've set it. But I am gonna use isset and see how it goes. Thanks :)
6:44 am on Sep 1, 2002 (gmt 0)

10+ Year Member

Only reason I bring it up is I've seen some strange stuff tacked on to URLs... not to mention a recent post about AOL hosing up search links with &'s in them.
9:51 pm on Sep 1, 2002 (gmt 0)

10+ Year Member

Hi Slade,
Thanks for the tip. It seems to work a lot better with the isset() function.

Here's the code I used

if (isset($_GET['type']) and $_GET['type'] != "") {
$this->menu_request = $_GET['type'];
} else {
$this->menu_request = "home";

isset($_GET['type']) checks to see if it's set, and $_GET['type'] != "" checks to see if it is empty. For example, if the ?type= has nothing for a value, it'll check that as well.

OK Slade, thanks once again.


Featured Threads

Hot Threads This Week

Hot Threads This Month