Solved

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

Posted on 2007-12-01
4
1,401 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
4 Comments
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Excellent.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now