I am running into a problem with a redirection code I am using. I would like to redirect people to a special website where only registered people can read the article. I am checking for the content and want to let people go to the new page and they should take the "article variable" with them so that they would be able to read it immidiately.

Here is the code I used:

<?php if ($premium =='yes')
              {
                header("Location: [url]http://www.bparis2.com/premium.php&articleId=[/url]<?php echo $row["pk_aId"]");
               }

And this is the error message i am receiving.

Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/bparis/public_html/articles.php on line 21

Does anybody know how I can overcome this problem?

Thank you in advance

Andrea

    I'm not quite sure what you're doing here, but the way I would do a redirect like this is...

    header("Location: [url]http://www.bparis2.com/premium.php?articleID=[/url]<some number>")

    You can pass the articleID with a GET variable.

    Was this wrong?

      i thought this was what i did. i take the articleId variable with me and place it into the new page. on that page use the get function. at least this is what i am trying to do. but i can't place this variable into the link i would usually write to pass a variable into another page.

      andrea

        i guess my problem is that i will pass a variable that it different each time the script is used. we are having around 6000 articles and we would like to pass a varable rather than a specific number.

        Here is the part that is not working:

        ("Location: http://www.bparis2.com/premium.php&articleId=<?php echo $row["pk_aId"]

        is there a different way i can pass a variable?

        andrea

          Where do you get the $row array from?

          Remember that if you want to do a header redirect it has to be at the top of the code... else it won't work.

          ok ...

            Typically users would access the links by clicking on hyperlinks. Right?

            So this is the deal. Create the links based on the database content.

            Article: "Jonny has a car" has articleID = 4
            Article: "Peter met Jonny" has articleID = 7

            So your list would look like this.
            <a href="http://somesite.com/premium.php?articleID=4">Andrea has a car</a>

            <a href="http://somesite.com/premium.php?articleID=7">Kristian met Andrea</a>

            I don't see where the redirect comes in? maybe you can tell me. Why do you need it when all you want to do is to show the article base on a database ID. hmm... Did I miss the point?

            kristian

              the problem is that maybe 2/3 of our website can only be accessed by people who pay for the service. the other 1/3 of the articles are free. therefore, we show part of the articles in the article.php file and the other articles on the premium.php page. i will give you the code so you can see where the $row comes into play:

              $articleId = @$GET["articleId"];
              $page = @$
              GET["page"];

              $result = mysql_query("select aLink3, pk_aId from tbl_Articles where pk_aId = '$articleId'");

              while ($row = mysql_fetch_array($result))
              {
              $premium = $row["aLink3"];

                   if ($premium == 'yes')
                      {
                      header("Location: [url]http://www.bparis2.com/premium.php&articleId=[/url]<?php echo $row["pk_aId"]");
                      }
                  }

              Maybe I am on the wrong track ;-)

              andrea

                OK!

                You're header statement is wrong.

                Remember that you're already inside of php codeblocks, so why do you say <?php echo $row['ph_aid']?

                Do this:
                header("Location: http://www.bparis2.com/premium.php?articleId=$row['pk_aId']");

                Use ? not &... & is for second an third argument...

                One more thing...

                Why the wile loop...? Don't you just get one hit?

                Hope this helps...

                  If i have this code

                  header("Location: http://www.bparis2.com/premium.php?articleId=$row['pk_aId']");

                  i get the following error:

                  Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/bparis/public_html/articles.php on line 21

                  i am sorry. it just doesn't work for me.
                  but thank you for your help anyway.

                  andrea

                    but something strange happens here. when i output $id than this shows be 'yes' and should have given me a number.

                    i guess php is not for me. but at least i try.

                    if ($premium == 'yes')
                    {
                    $id = $row["pk_aID"];
                    echo $id;
                    header("Location: http://www.bparis2.com/premium.php?articleId=$id");
                    }

                      thank you. and have a good night. i will let you know if it works

                        you are my hero!

                        thank you so much. i worked on it for days.

                        andrea

                          I'm still awake cause I couldn't sleep until I knew you were happy!
                          I guess I'm pretty slow in the evenings... I apologize for that.

                          good luck on your work... and I'll see you around

                            Write a Reply...