1.11M Members

Header Location = $var

 
0
 

Hi Everyone, I am helping a good friend of mine to design a website, but we have got a bit stuck -
Hoping someone can help us out.
We are trying to add a var from our database into the header location.
like this -

header( "Location: resend.php?activate=$mobnumid");

Here is the complete code.

        if($smsmobnum != '') {
            $qry = "SELECT * FROM tbl_name WHERE var='$var' and var2='$var2' and var3='0'";
            $result = mysql_query($qry);
            if($result) {
                if(mysql_num_rows($result) > 0) {

                    while($row_data = mysql_fetch_array($result)){

                $mobnumid = $row['id'];

        @mysql_free_result($result);
                header( "Location: resend.php?activate=$mobnumid");
                exit();
        //$b1=false;
                }       
            }
        }
    }

We are checking the database for an existance from our select query

If our results are true, ie. >0
then when would like to add the var $mobnumid to the header location. Like above
The page is redirecting correctly, but our variable $mobnumid is not being added.

What is it that we are missing?
Many thanks

 
0
 

try this to test:

if($smsmobnum != '') {
        $qry = "SELECT * FROM tbl_name WHERE var='$var' and var2='$var2' and var3='0'";
        $result = mysql_query($qry);
        if(mysql_num_rows($result) > 0) {
                while($row_data = mysql_fetch_array($result)){
                    $mobnumid = $row['id'];
                    echo 'use this: ' . $mobnumid;
                    //header( "Location: resend.php?activate=$mobnumid");
                    //exit();
                }       

        }
}
 
0
 

@diafol - Thanks for your help.
I reread the code and found the following problems.
$mobnumid = $row['id']; should be
$mobnumid = $row_data['id']; - that would help with getting the var
I then need to to concactinate the var to header location like this
header( "Location: resend.php?activate=".$mobnumid);
All working great now thanks,

Question Answered as of 1 Year Ago by diafol
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article