1

I'm getting this error when I try to access my php file. It says that the link was not found on the server. I tried echoing the link it returns, I got the correct link and when I try to access it manually, it loads but when I use redirect, I get the error.

This is my code:

<?php
    session_start();

    $user_id = $_SESSION['user_id'];
    $api_id = $_SESSION['api_id'];
    $limit =  $_SESSION['limit'];

    $final_link = 'http://www.mywebsite.info/payment/public/createPayment/' .$user_id .'/' .$api_id .'/' .$limit;
    echo $final_link;
    header('Location: .$final_link');
    exit;
    unset($_SESSION["user_id"]);
    unset($_SESSION["api_id"]);
    unset($_SESSION["limit"]);
?>
zoenightshade
  • 159
  • 2
  • 12
  • Possible duplicate of [What is the difference between single-quoted and double-quoted strings in PHP?](https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – Nick May 29 '18 at 03:39

2 Answers2

0

Try this:

<?php
session_start();

$user_id = $_SESSION['user_id'];
$api_id = $_SESSION['api_id'];
$limit =  $_SESSION['limit'];

$final_link = 'http://www.mywebsite.info/payment/public/createPayment/' .$user_id .'/' .$api_id .'/' .$limit;
echo $final_link;
header("Location: {$final_link}"); // changed in double quotes
exit;
unset($_SESSION["user_id"]);
unset($_SESSION["api_id"]);
unset($_SESSION["limit"]);
?>
Pang
  • 9,564
  • 146
  • 81
  • 122
Dinesh Ghule
  • 3,423
  • 4
  • 19
  • 39
0

Try this:

<?php
session_start();

$user_id = $_SESSION['user_id'];
$api_id = $_SESSION['api_id'];
$limit =  $_SESSION['limit'];

$final_link = 'http://www.mywebsite.info/payment/public/createPayment/' .$user_id .'/' .$api_id .'/' .$limit;
//no echo before header()
header("Location: $final_link"); // changed in double quotes
echo $final_link;
exit;
unset($_SESSION["user_id"]);
unset($_SESSION["api_id"]);
unset($_SESSION["limit"]);
?>
Pang
  • 9,564
  • 146
  • 81
  • 122