We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,047 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Header Location = $var

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

2
Contributors
2
Replies
18 Hours
Discussion Span
4 Months Ago
Last Updated
3
Views
Question
Answered
everton.retweets
Newbie Poster
2 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 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();
                }       

        }
}
diafol
Keep Smiling
Moderator
10,653 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57

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

everton.retweets
Newbie Poster
2 posts since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 4 Months Ago by diafol

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0891 seconds using 2.67MB