this is in my config.php function redirect($url){ header('Location: '.$url); } PHP: this code is in my edit-catchment.php redirect('index.php'); PHP: but now i receive the following error now this is bugging me so much as i cannot find such an error. I have cleared all of the white spacing double checked the spelling. I am truly in need of other opinions here, maybe a fresh set of eyes will be able to spot what i am missing.
If you want a quick fix, try to add ob_start(); PHP: at the very beginning of your script. Other than that, you can use a JavaScript call to redirect like : <script type="text/javascript" language="javascript"> setTimeout("location.href='index.php'", 0); </script> Code (markup):
@ nico_swd, right so this is the content of my header.php <?php include '../config/config.php'; ?> <html> <head> <title>**title**</title> <link type="text/css" rel="stylesheet" href="<?php site_root();?>css/styles.css"/> </head> <body> <div id="headerdoc"> <h1>**header**</h1> </div> <div class="menu"> <ul> <li><a href="<?php site_root();?>admin/index.php">Home</a></li> </ul> </div> <div id="under_layer"> <div id="wrapper"> <div id="content"> PHP: i do not see anything wrong here. @dujmovicv, I have already tried the ob_start(); and that makes no change.
You are not able to change header when anythins is printed in the page. You only can call header function before "print" and "echo".
Yes, you do. but it's not possible to call redirect() in site_root(). Solution: 1. Alternatives like meta tag or javascript location 2. Using ob_contents to put output in a variable, then if output was ok, print that.
ob_content is an area i have not gone into much, is there perhaps a reference of a website that i can read more about it. also would it not be a better quick fix to just get rid of the site_root() function and manually put in the site root
ob_get_content simple example from php.net: <?php ob_start(); echo "Hello "; $out1 = ob_get_contents(); echo "World"; $out2 = ob_get_contents(); ob_end_clean(); var_dump($out1, $out2); ?> PHP: As a quick fix, just call header() and redirect() out of site_root().
After the header() in redirect method, add an exit() or die() statement right after, your code should work. If that doesn't work. Download notepad++, open the header/config files then Menu -> Encoding -> utf8 without BOM. One of the files should have some weird characters (sequence bytes). Another solution I find helpful is copying the file contents, opening notepad and pasting it in a different file. Then overwrite the old file with the new one.
<?php ob_start(); function redirect($location){ header('location:'.$location); } redirect('index.php'); include '../config/config.php'; ob_flush(); ?> PHP: Give this a try.
i have given this a try but it is still not working as the function is in a config page and the calling of the function is on the edit page and in between the function and calling of the function there is a include'header.php', and in the header.php i have echo out the site root function and it is conflicting with the redirect function even if i put the ob_start and ob_flush.