1

In my project at one place I use the following line of code but with this code server shows server error 500. and my code is.

header("location:../../views/tileesDesign/viewAlbum.php?album='".$_GET['album']."'&com_id='".$_GET['com_id']."'&d_id='".$_GET['d_id']."'");

This line generate server error, without this line I have no error. and I think problem with header location query string.

so, help me to how query string should define in header function?

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Divyesh Jesadiya
  • 1,105
  • 4
  • 30
  • 68

1 Answers1

2

Remove the single quotes around the querystring parameter values

header("location: ../../views/tileesDesign/viewAlbum.php?album=".$_GET['album']."&com_id=".$_GET['com_id']."&d_id=".$_GET['d_id']);

Or to make it even easier to read and debug

header("location: ../../views/tileesDesign/viewAlbum.php?album={$_GET['album']}&com_id={$_GET['com_id']}&d_id={$_GET['d_id']}");

And using this sample code from the command line and faking up a $_GET array containing all the required occurances :-

<?php
//header("location: ../../views/tileesDesign/viewAlbum.php?album=".$_GET['album']."&com_id=".$_GET['com_id']."&d_id=".$_GET['d_id']);
$_GET = array('album' => 'aaa', 'com_id'=> 'bbbb', 'd_id'=>'ccc');

echo "location: ../../views/tileesDesign/viewAlbum.php?album=".$_GET['album']."&com_id=".$_GET['com_id']."&d_id=".$_GET['d_id'];
echo PHP_EOL;
echo "location: ../../views/tileesDesign/viewAlbum.php?album={$_GET['album']}&com_id={$_GET['com_id']}&d_id={$_GET['d_id']}";

Generates this putput from either of the above options:-

location: ../../views/tileesDesign/viewAlbum.php?album=aaa&com_id=bbbb&d_id=ccc

location: ../../views/tileesDesign/viewAlbum.php?album=aaa&com_id=bbbb&d_id=ccc
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149