SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    With a GET statement the header will not execute

    I have already successfully written some header programs. They have all used the post method:

    Code:
    $data = filter_input(INPUT_POST, "data1");
    I am using the get method this time:

    Code:
    $idget = $_GET['id'];
    The header resides in an "if" statement and the equation is satisfied but the header will not execute.

    Is it just the equal sign in the get statement?

    If so how do I get around the equal sign to execute the header.

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have you tried to use header()?
    coming soon sitejuju.com my new development portfolio

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is a header statement in the if statement dependent upon the Get statement in question.

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you provide the code so i can get a look at it
    coming soon sitejuju.com my new development portfolio

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is my code:

    $idget = $_GET['id'];
    $conn = mysql_connect('localhost', '$user', '$pass');
    mysql_select_db('database1');
    $sql = "SELECT `id` FROM `table1` WHERE index = '$idget'";
    $result = mysql_query($sql, $conn);
    $idi = mysql_fetch_array($resulti, MYSQL_ASSOC);
    if ($idi == ""){
    return header("http://www.site.com/index.htm");
    }
    mysql_close($conn);

  6. #6
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if(isset($_GET) && isset($_GET['id'])){
        
        
    $idget  mysql_real_escape_string($_GET['id']);
        
    $conn   mysql_connect('localhost'"$user""$pass"); mysql_select_db('database1');
        
        if(!
    is_resource($conn)){
            die(
    'Connection Error');
        }
        
        
    $sql    "SELECT `id` FROM `table1` WHERE index = '$idget'";
        
    $result mysql_query($sql$conn);
        
    $idi    mysql_fetch_array($result MYSQL_ASSOC));
        
        if(
    $idi == "" or $idi == FALSE){
            
    header('Location:http://www.site.com/index.htm');
        }

    also you need to test each line as you write it to make sure it is doing the things you want it to do or expecting. I found alot of errors just in that little bit of code so please test it will help you learn and no bald from ripping your hair out trust me im bald its not good.!
    coming soon sitejuju.com my new development portfolio

  7. #7
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The whole problem is with the:

    $idi = mysql_fetch_array($result , MYSQL_ASSOC));
    It will not accept the null condition. It gives the error:

    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in c:/path/file.php

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that means your query is failing and returning FALSE. witch it should be returning the ID?
    coming soon sitejuju.com my new development portfolio


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
  •