Navigating results from MySQL and problem with POST link

I am trying to dynamically display results that I retrieve from my database i.e. only 5 results per page and code should automatically compute how many pages it needs and create links for each page. I have also added a link at the top of my page so that if user wants to POST new data he can post it. Problem is that when I click on page 2 or 3 or any numbered page and click on POST link it gives me following error (however when it is loaded for the first time and I am on page 1 and I click on POST then it takes me to POST page but if I click on page2 and then back on page1 link then it gives me same error when I click on POST)


"CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

And it did not tell about any header etc.
[/b]

deleted the other post! one should be enogh!

plaese give us some more information: server, php-version, relevant code.

sound’s to me like a session problem. try to look in ur code for header() and session_*() functions.

I am using IIS, PHP5.2.4 and MySQL. Here is the code that I am trying to use and I dont have any header and session information in my code ( I am a new programmer).


<head>
<h2>POST</h2>
<a href="post.php"><b><font size="4">Post!!</font></b></a>
</head>

<?php

if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 

// Define the number of results per page 
$max_results = 5; 

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results);  

// Perform MySQL query on only the current page number's results 

$sql = mysql_query("SELECT * FROM MYDB LIMIT $from, $max_results"); 

while($row = mysql_fetch_array($sql)){ 

	echo "<hr>";

   	echo "<b><font color='#660000' size='4'>".$row['NAME']."</font></b>";
	echo "<br>n";
    
    } 

// Figure out the total number of results in DB: 
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM MYDB"),0); 

$total_pages = ceil($total_results / $max_results); 

// Build Page Number Hyperlinks 
echo "<hr><center>Select Page<br />"; 

// Build Previous Link 
if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href="".$_SERVER['PHP_SELF']."?page=$prev"><<Previous</a> "; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href="".$_SERVER['PHP_SELF']."?page=$i">$i</a> "; 
    } 
} 

// Build Next Link 
if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href="".$_SERVER['PHP_SELF']."?page=$next">Next>></a>"; 
} 
echo "</center>"; 
?> 

[/code]

Main thing is that I have a database in MySQL and I am successfully retreiving data from it. Now I want to display only 5 results per page and dynamically create those pages with NEXT and PREVIOUS links and on each page I want to have a link for POST so that if someone wants to post something while viewing page2 he should be able to do that. But using code listed above I have successfully created NEXT and PREVIOUS links but POST link does not work from pages and when I click on POST link it gives me this error

"CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

and then it does not return any header may be because I am not using any error. Please guide me or recomment me what kind of code should I be using to dynamically display my results and also to have POST link on each page. Thanks

when i have a look at the code u posted it seems that the error appeares after accessing ‘post.php’.
but it seems that was not the file u posted, was it?

btw:
has to be ‘<<Previous’ and ‘Next>>’
(< meany lower than, > means greater than. and is used to make clear that u don’t mean a tag )

Thanks for correcting previous and next. Error appears everytime I go to page2 or 3 and try to access post.php except that for the very first time my page loads it allows me to access post.php but as soon as I go to other pages and try to access post.php it gives me an error.

can u give us the code of post.php?

Actually I am at work and can only give quote after 2 hrs. However its a simple form in which I am just asking users tp type in their name and address. Information from this form is sent to another php code that processes the data received from post.php and send it to MySQL. Then using the code I have pasted above I am trying to retrieve data from MYSQL and display it.

but post.php is the file producing the error, and i have a lot of time.

just post it as soon as u r able 2. otherwise i’m afraid, i cant help u.

wow look to me as there are a lot of errors in there expacely a missing -tag

don’t think that is creating ur error but:

[code]

POST

Enter Data

Post Data

Name:




Address:




[/code]

why is it a .php file? it’s plain html!

naming it.php is the cause of this error I am getting?

I changed it to html and now I m not getting that CGI error but when I click on POST link from different pages it does not open POST form.

Sponsor our Newsletter | Privacy Policy | Terms of Service