In my localhost a pagination links working but in live server it wont it stuck

when i click to link and its also display data in print_r() function but it wont redirect to my list page , i am stuck on header(“location:student-list.php?id=1”); , it also dosent give me any error.

  1. link page : href=“student-list-pagination?name=all”

  2. Student list pagination.php

<?php include("config.php");?>
<?php include("header.php");?>
<?php

if($_REQUEST['name']=='all')
{ 

$q=mysql_query("SELECT * FROM userdata ORDER BY id DESC",$con);
while($row=mysql_fetch_array($q))
{
$all[]=$row;

}
$_SESSION['allstudent']=$all;
header("location:student-list.php?id=1");

}
?>

after that $_SESSION[‘allstudent’] data is printed but wont redirect on student-list page…
please give me a advise …thanku

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

http://php.net/manual/en/function.header.php

1 Like

yes But I removed every unused Space Before The Header location . but it also wont work .
And i also get $_SESSION[‘allstudent’]=$all Data but i want that data before i called header function

Won’t this:

<?php include("config.php");?>
<?php include("header.php");?>
<?php

include two carriage-return whitespace characters, one at the end of each closing PHP tag, which might cause the issue with the header output?

<?php
include("config.php");
include("header.php");
...

would eliminate that as a cause. Also have a look at either mysqli or PDO methods of accessing data - the old-style MySQL calls are deprecated so for new code, you shouldn’t really use them.

1 Like

Are you 100% certain? Whitespace can not always be easily “seen”. As droopsnoot said, CR, LF, NL and even BOM can cause a “headers already sent”.

Does your text editor have a “show symbol” or equivalent option?

1 Like

Also check files you include at the beginning (config.php, header.php).
They shouldn’t contain any output too.

1 Like

Yes, header.php is probably the issue. Move it down below header("location: ← be sure there is a space here.

header("location: student-list.php?id=1");
include "header.php";
1 Like

**Thank you all For The help I really appreciate your Help . After All of your Suggestions , I removed my PDO objects and upload in new server so thanks to all and also i get a new knowledge from you so thanku **

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.