English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i had a header and before the header i had the codes for connecting to mysql and i didnt have any problem with that.
but after i changed the mysql codes to an inc file i got this error:
Warning: Cannot modify header information - headers already sent by ......
anybody knows what should i do?

session_start();
include ("mysqlconnect.inc");
if (asdasd)
header("Location: http://asdadsdd");

and here there is no way that i can put the header before the include file cause my if statement use the data from my database

2006-06-30 12:10:39 · 4 answers · asked by aryaxt 3 in Computers & Internet Programming & Design

Waynez lol sweet :)
the problem was exactly what u said thx :)

2006-06-30 12:24:33 · update #1

4 answers

Er, okay...

There are a couple of things that could do it.
First off, I don't think that after inclusion, you can use any other header commands (I don't know why). Here are some things you can do.

1: You can create another include file to do the headers, so your code looks like this.

---start.php---
session_start();
include ("mysqlconnect.inc");
if (asdasd) include ('redir.inc');
?>
---redir.inc---
header("Location: http://asdadsdd");
?>
---

2: You can remove the entire mysqlconnect.inc file and paste it into the other file, but I wouldn't.

3: You could add into mysqlconnect.inc a command to redirect, so it looks like this

---mysqlconnect.inc---
function connect() {
...
}
function query($query){
...
}
function redir($location) {
header("Location: $location");
}?>
---start.php---
session_start();
include ("mysqlconnect.inc");
if (asdasd) {
$location = "http://asdadsdd";
redir ($location);
}
---

Whichever way works for you.

2006-06-30 15:05:48 · answer #1 · answered by Anonymous · 0 0

good day, I actually have some questions as each little thing seems good and could paintings. First issues first, purely remember to have blunders dealing with became on. Do you get any mistakes in any respect displayed? try growing to be a known blunders like a variable without $ in the front of it or a function that does no longer exist. See if any mistakes are exhibited to the web page. is likewise it only a sparkling web page that receives displayed? if so are you able to placed up the content.own domicile web page document besides? Do you've something on your connection.own domicile web page or your purposes.own domicile web page which will be showing something earlier the header became despatched? try echoing something in spite of everything that own domicile web page code outdoors the if reality.

2016-11-30 01:42:25 · answer #2 · answered by ? 3 · 0 0

I bet you have an empty line or a space at the top of your file that calls the include, or else an empty line or a space at the top or bottom of the include file itself.

I hate it when I do that.

Make sure there are no spaces or lines before "" in the include file and that there are none before "

2006-06-30 12:20:14 · answer #3 · answered by Waynez 4 · 0 0

Hi,

add this after
session_start();

ob_start();

And at the end of your current document after all of your code
add this

ob_end_flush();
?>

Try it and if it works .... :)) 2 bears, please :)

Regards,
Stefan

2006-07-01 03:09:07 · answer #4 · answered by Stefan Grudov 1 · 0 0

fedest.com, questions and answers