Header("location: $random_link") Redirection issue PHP

Viewed 41

Hey there I stuck into a problem with header() in php I create a database where i stored 10-15 random urls. On every page reload the code below runs.

$connection = mysqli_connect("localhost","USER","PASSWORD","DB");
$query = "SELECT * FROM table ORDER BY RAND() LIMIT 1";
$result = mysqli_query($connection,$query);
$row = mysqli_fetch_assoc($result);
$link = null;
$link = $row['link'];
header("location: ".$link."");

but it is redirecting me to a single url every time. it has to redirect me on a random url because it is working on localhost but when I upload this on server it is not working. It is redirecting me on a single url every time I contact to support of the server they cleared and disabled the server cache but I am still facing the issue.

0 Answers
Related