Skip to main content
Inspiring
August 17, 2008
Question

PHP Code Help

  • August 17, 2008
  • 1 reply
  • 247 views
I have the following code:

header('Location: time_entry.php');

I need to change the location to the following:

employee_view_entry.php?period_id=<?=$row['period_id']?>&user_id=<?=$timeapp_id?>

Can someone please show me how to make this work without getting a string error? I am sure it has to do with ( ) and ' ' mark placment.

Please advise and thank you in advance!
This topic has been closed for replies.

1 reply

Inspiring
August 17, 2008
.oO(bcounts)

>I have the following code:
>
> header('Location: time_entry.php');
>
> I need to change the location to the following:
>
>
>employee_view_entry.php?period_id=<?=$row['period_id']?>&user_id=<?=$timeapp_id?

Two things:

* The Location header requires an absolute URI.
* Avoid short open tags, they are unreliable. Use <?php ... ?> instead.

> Can someone please show me how to make this work without getting a string
>error? I am sure it has to do with ( ) and ' ' mark placment.

$uri = sprintf(' http://%s/%s?period_id=%s&user_id=%s',
$_SERVER['HTTP_HOST'],
'employee_view_entry.php',
$row['period_id'],
$timeapp_id
);
header("Location: $uri");

Micha