I have the following code that selects a random website from the database and redirects the user to the target website through our tracking system. It works fine locally however when running it on the production server it displays the IE7 stock standard error message (Internet explorer cannot display this page). Could anyone suggest how to rewrite this as to not run into the error. <?php require_once('../dbconnect.php'); $query = "SELECT url FROM proxylist"; $result = mysql_query($query); $numberofproxies = mysql_num_rows($result); $chosen_number = rand(1, $numberofproxies); $x = 0; while ($row = mysql_fetch_array($result)) { $x++; if ($x == $chosen_number) { header('Location: http://localhost/proxypot/ccd/index.php?xrl=http://www.' . $row['url']); // send to random url exit; // make sure the script exits after forwarding } } ?> PHP: I know that the file is in place on the production server as if I comment everything and add an echo line at the end there is no problem with loading Thanks
header('Location: http://localhost/proxypot/ccd/index.php?xrl=http://www.' . $row['url']); // send to random url change the location of your site its looking for localhost not your site
When you use header redirects, add this right after <?php ob_start(); PHP: and this before ?> ob_end_flush(); PHP: Then you can use headers all you want. If you use exit() or die() at the end of your script, ob_end_flush() comes just before that.
I just had a look up on those functions. If I am not intending to output anything should I still use ob_start() and ob_end_flush()?