hello My PHP code is : <?php $myname = ' its come from input text $filename = "/home/public_html/namelink.txt"; $fp = fopen ($filename, "r"); while (!feof($fp)) { $line = fgets($fp, 1024); list ($field1, $field2) = split ('#', $line); if ($field1 = $myname) { header("Location: http://www.mydomain.com"); exit; } $fp++; } fclose($fp); ?> i am getting an error : Cannot modify header information - headers already sent please suggest me how to solve this error Thanks
Have you used echo before header("Location.............|) ? If yes it will give you an error if no, then paste complete code here or in pm so that I can help you. Thanks
I am not sure if it can be as simpel as on this line change $myname = ' its come from input text to $myname = ' its come from input text '; you could also try changing if ($field1 = $myname) to if ($field1 == $myname) you can also remove this "$fp++; " Hope some of the above help
its a complete code i hav not change anything i am having a if statment in while loop if i get the match i redirect it to some of my domain
Well first off the $myname = ' its come from input text is definitely wrong. It's not closed at all. That's probably not the root of the error, but does need fixed. Secondly make sure there is NO whitespace before or after <? ?>
$line = split("\n", file_get_contents("namelink.txt")); foreach( $line as $data ) { $segs = split( "#", trim($data) ); if($segs[0] == $myname ) { header("Location: http://www.mydomain.com"); exit; } } ?> PHP: ??? If you could post nameslist.txt that would be good .....
I have had same problem . In my case it was due to some blank lines at the end of the file . I mean after ?>. It was for I was using notepad to code. Notepad keeps the blank line may be. Then I have copied the code to wordpad and tried , my problem solved. You could try this, thanks