SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with setting variable to null

    Hi,

    I am trying to set up links that make change the file included on a webpage as i have done before so that a link would be www.mydomain.com/index.php?page=link for example i can get it to work fine using the following code...
    PHP Code:
    if ("$page== "$null") { include ("none.txt"); }
    elseif (
    "$page== "link1") { include ("link1.txt"); }
    elseif (
    "$page== "link2") { include ("link2.txt"); }
    elseif (
    "$page== "nowt") { include ("nowt"); }
    else print 
    "Sorry the $page page does not exist yet :P"
    however it produces errors such as....
    Warning: Undefined variable: page in c:\apache\htdocs\links.php on line 13

    Warning: Undefined variable: null in c:\apache\htdocs\links.php on line 13
    it is strange becasue the php code works as can be seen here in this test page (note hosted on my pc so may not b up 24/7) but still produces errors in asking me to define teh variables $page and $null which i have already done....

    If anyone can help me i would be very grateful,

    Thanks in advance,

    BGM

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do this instead, your if statements weren't correct:

    PHP Code:
    if (!isset($page)) { include ("none.txt"); }
    elseif (
    $page == "link1") { include ("link1.txt"); }
    elseif (
    $page == "link2") { include ("link2.txt"); }
    elseif (
    $page == "nowt") { include ("nowt"); }
    else print 
    "Sorry the $page page does not exist yet :P"
    ck :: bringing chris to the masses.

  3. #3
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats absolutely great cheers

    you have made me very very happy lol


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •