Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-12-01
4
Medium Priority
?
1,417 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 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

661 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