Solved

PHP Warning: Cannot modify header information - headers already sent by...

Posted on 2007-12-01
4
1,411 Views
Last Modified: 2013-12-12
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/db/mysql4.php on line 317

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/db/mysql4.php on line 317

Warning: Cannot modify header information - headers already sent by (output started at /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/db/mysql4.php:317) in /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/includes/page_header.php on line 479

Warning: Cannot modify header information - headers already sent by (output started at /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/db/mysql4.php:317) in /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/includes/page_header.php on line 485

Warning: Cannot modify header information - headers already sent by (output started at /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/db/mysql4.php:317) in /mounted-storage/home43a/sub004/sc31952-BMDX/www/forum/includes/page_header.php on line 486


I keep getting that warning in lines 479, 485 and 486, here is the code of that file at those lines of the page_header.php:

// Work around for "current" Apache 2 + PHP module which seems to not
// cope with private cache control setting
if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2'))
{
      header ('Cache-Control: no-cache, pre-check=0, post-check=0'); //line 479
}
else
{
      header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header ('Expires: 0');//line 485
header ('Pragma: no-cache'); //line 486

$template->pparse('overall_header');

?>

Code of the mysql4.php:

            if ( $query_id )
            {
                  unset($this->row[$query_id]);
                  unset($this->rowset[$query_id]);
                  mysql_free_result($query_id); //line 317

                  return true;
            }

What am I doing wrong?
0
Comment
Question by:axtur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390142
axtur:

There is nothing wrong with your line 479, it is simply because your error messages for your mysql_free_result(): function has been written to the browser, therefore the header() function cannot execute properly.

Solving the mysql_free_result(): error message will also solve your other errors!

Hope this helps.
0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 500 total points
ID: 20390370
mysql_free_result($query_id); is not a resource.

you should first check if its a resource and then use mysql_free_result. mysql_query() will only return a resource on SELECT, SHOW, EXPLAIN and DESCRIBE queries.

use this code to check.
 if ( $query_id )
            {
                  unset($this->row[$query_id]);
                  unset($this->rowset[$query_id]);
				  if(is_resource($query_id)) {
                     
					 mysql_free_result($query_id); 
				  
				  }
                  return true;
            }	  

Open in new window

0
 
LVL 14

Expert Comment

by:profya
ID: 20390739
The problem is with line 317, make sure that you are connected to the database before you can run a query.
0
 

Author Closing Comment

by:axtur
ID: 31412158
Excellent.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question