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

Recommended Answers

All 2 Replies

Member Avatar for diafol

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();
                }       

        }
}

@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,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.