Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to redirect some urls that were used under vBulletin but I can't get the PHP code to work
if any number is in the url p value I want it to pass through to the t value - that part works fine,
but when the p value is equal to 724166 then I want the $forum value changed to 2330,
that part does not work.

what I want it to do is:
if the incoming url has p=724166 in it
then I want it to change $forum to 2330 and output t=2330
but that if statement does not work for some reason???

What I have tried:

<?php
if (!empty($_GET['p']))
{
    $forum = (int) $_GET['p'];
    if ($forum = 724166)
    {$forum = 2330}
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://hundredbling.net/viewtopic.php?t=' . $forum);
}
?>


<?php
if (!empty($_GET['p']))
{
    $forum = (int) $_GET['p'];
    if ($forum == 724166)
    {$forum = 2330}
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://hundredbling.net/viewtopic.php?t=' . $forum);
}
?>


when I try either of these the output is usually the same

http://hundredbling.net/viewtopic.php?t=724166.0

I don't understand why it does not change to t=2330 and I also don't understand why it adds the .0 on the end?
Posted
Updated 1-Apr-18 4:58am
v3

1 solution

if ($forum = 724166)

Surely, you mean == not = .

[edit]
Since you updated your question with the critical information, the answer is that you should be treating 724166, 2330 and so on as strings, not numbers. Wrap them in quotes so $forum becomes a string type, not a number.
[/edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900