I need help in a test page i am doing in php

Discussion in 'PHP' started by _level_, Nov 15, 2007.

  1. #1
    Hey i am not completely new to php but i need a bit of help.
    I am trying to do a testing.php page.
    i want the page to handle errors for empty input boxes.
    Now i want it to do testing.php?error=1 then display the error message.
    I have tryed a few codes that did not work but maybe should.

    the first code i tryed was with switch statement like this.

    switch($error) {
    case 1:
    echo "Error Number 1";
    break;
    case 2:
    echo "Error Number 2";
    break;
    }

    now that code didnt work.
    so i tryed a simple if statement like this.

    if ($error == "1") {
    echo "Error Number 1";
    }
    if ($error) == "2") {
    echo "Error Number 2";
    }

    again didnt work when i type in testing.php?error=1 or testing.php?error=2 alll i get is a blank white page.
    can any one explain a bit on how this is done?
     
    _level_, Nov 15, 2007 IP
  2. salmanshafiq

    salmanshafiq Well-Known Member

    Messages:
    260
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #2
    hi code is absolutely fine. but may b the problem is it's treating the $error as a varChar not Number so please update code in this way.

    
    $error=$_REQUEST['error'];
    switch($error) {
    	case "1":
    		echo "Error Number 1";
    		break;
    	case "2":
    		echo "Error Number 2";
    		break;
    }
    
    PHP:
     
    salmanshafiq, Nov 15, 2007 IP
  3. _level_

    _level_ Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you i just tryed that code out and it worked.
    tell me can the same method be used when doing a if statement?
    it seems as if it can by just using request method.
     
    _level_, Nov 15, 2007 IP
  4. _level_

    _level_ Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i have 1 more question regarding this how do you get a page inside a page like the code you posted that helped now my page can do test.php?error=1 now what if i want my page to do like test.php?error=1&test=1 and that takes me to the test=1 page is that possible?
     
    _level_, Nov 16, 2007 IP
  5. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #5
    use include inside the if statements.. or put the include inside a div container for css purpose
     
    bartolay13, Nov 16, 2007 IP
  6. _level_

    _level_ Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    what do you mean include inside the if statements?

    so far i have

    $error=$request['error'];
    switch ($error) {
    case "1":
    echo "error 1";
    break;
    case "2":
    echo "error 2";
    break;
    }

    now i want to take this switch statement and make the test.php page go to test.php?error=1&e=2 now the ?error=1 part works but i cant seem to make the page work with e=2 it always gos back to the main page of the test.
     
    _level_, Nov 16, 2007 IP
  7. _level_

    _level_ Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Here is what i am trying to complete.
    i am making a php fusion type page for movie listing.
    Now when the user clicks a categorie for movies say Horror the page movielist.php will go to horror like movielist.php?state=Horror now that works but i want the horror page to only display 10 movies per page so that means the sub page Horror needs to have a &page=1 added on to it.
    so the link would be movielist.php?state=Horror&page=1 now state works that displays the movies but the &page=1 part does not work that just takes me back to the main movielist.php page.
    so my question now is how do i add a subpage on a subpage so that the &page=1 will work properly.
     
    _level_, Nov 17, 2007 IP
  8. salmanshafiq

    salmanshafiq Well-Known Member

    Messages:
    260
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #8
    i can't understand what you want. if you uploaded your site then give me link i'll help you out regarding this issue
     
    salmanshafiq, Nov 18, 2007 IP
  9. _level_

    _level_ Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    sure my site is demons-revenge.com/MovieList.php now thats my page so far.
    when you go to the url your notice that it has 4 categories Horror Comedy Action and Drama now when you click horror the horror movies display but what i want now is for that page to have a second page added on the url will be demons-revenge.com/MovieList.php?state=Horror
    and i want that horror page to have new pages on it so that the movies will show 10 per page.
     
    _level_, Nov 19, 2007 IP