Solved

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

Posted on 2007-12-01
4
1,414 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

632 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