vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Strange "Cannot modify header information" error (https://vborg.vbsupport.ru/showthread.php?t=283357)

Boofo 05-23-2012 11:24 AM

Strange "Cannot modify header information" error
 
I am getting this error whenever I do a search for a quote name in a mod I did a long time ago. It just started happening after I upgraded to 4.1.12 PL1 a few weeks back. The strange thing is I can edit quotes and do a "Find All Quotes" listing fine, but if I try to search for a quote name, I get the error. But not on all names. It seems to be sporadic.

The quotes are in the db, not a file. Does anyone have any idea why this is happening now when it was fine before?

Quote:

Warning: Cannot modify header information - headers already sent by (output started at [path]/includes/adminfunctions.php:299) in [path]/includes/functions.php on line 4116

Boofo 05-27-2012 05:41 AM

I've narrowed it down to the if ($numresults == 1) conditional from this code:

Code:

if ($numresults == 1)
{
        $quote = $db->fetch_array($getquotes);
        exec_header_redirect("quote.php?" . $vbulletin->session->vars['sessionurl'] . "quoteid=" . $quote['quoteid'] . "&do=update");
}
else if (!$numresults)
{
        print_stop_message('no_quotes_matched_your_query');
}
else
{


I only get the error if there is just one result. Any more than 1 result and everything works fine. Does anyone have any idea why it is doing this and how to fix it?

Simon Lloyd 05-27-2012 06:20 AM

What happens if you modify it to <= or => rather than == ?

Boofo 05-27-2012 06:50 AM

No change. I tried that first. I did find a fix that works, however. I added this to the top of the page (above the <?php), so it now looks like this:

Code:

<? ob_start(); ?>
<?php


and this to the bottom of the page (below the ?>), so now it looks like this :

Code:

?>
<? ob_flush(); ?>


And now the error is gone. I looked at the file in CPanel, but I couldn't see any UTF-8 BOM in the file at all, so I was stumped.

Simon Lloyd 05-27-2012 02:31 PM

Doh!, i should have thought of that, you don't have to add it to the page though, it should be able to go in the plugin :), i use similar in some of my plugins :)
PHP Code:

ob_start();
   include(
'mystuff.php');
   
$stuff ob_get_contents();
ob_end_clean(); 


Boofo 05-27-2012 02:56 PM

Well, it's a file for my quotes mod. It doesn't have any plugins. Like I said earlier, there was no BOM in the file so I have no idea what changed in vB 4.2.0 to start giving that error. My site did move to another server recently, but IIRC, it as showing that error after I upgraded and before the move. But the file is an older one. I think I am using the same code in it as I did for vb 3.5, but it has always worked fine except for the error.

Simon Lloyd 05-27-2012 06:45 PM

If it works regardless of the error just supress the erro, do you think its down to deprecated code?

Boofo 05-27-2012 06:55 PM

Quote:

Originally Posted by Simon Lloyd (Post 2333585)
If it works regardless of the error just supress the erro, do you think its down to deprecated code?

If it was deprecated code, you would think PHP would show that, I would think, wouldn't it?

Simon Lloyd 05-27-2012 07:17 PM

it depends whether the error reporting is set right for your version of php :), you know, where you saw "E_Error ~ALL" and other types of reporting, you had to add 8192 (i think, dont quote me on it) at one point, deprocated errors didnt come along until php5.3.x, take a look here http://php.net/manual/en/function.error-reporting.php

Boofo 05-27-2012 07:28 PM

I am on PHP 5.3.10 and MySQL Version 5.5.22-cll. This is what I am using in the file:

Code:

error_reporting(E_ALL & ~E_NOTICE);

One thing has got me thinking though. It was something Paul said about UTF-8 BOM. My tables in the db are all set at:

Code:

CHARSET=utf8 COLLATE=utf8_unicode_ci

I'm wondering if that could be any part of that is going on.


All times are GMT. The time now is 11:37 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01155 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete