1

I'm currently working on a site with authentication using PHP sessions with a database. i dont know how to solve this.

header("location:singleprod.php?product_id=$row['product_id']");

the header is not working. The error shown is Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

Any help please.... Thanks in advance.

  • What appears in the browser after re-direction? – Carl Binalla Jun 19 '17 at 06:10
  • quick solution will be to add ob_start at the first line of the file just next to the php opening tag like – manian Jun 19 '17 at 06:11
  • its not getting redirected. The error Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) is shown – Ayanti Goswami Jun 19 '17 at 06:12
  • The code is basically some thing like this.. if (!$result_insert_user) { echo 'Query Failed '; } else { header("location:single_prod.php?product_id=$row['product_id']"); } – Ayanti Goswami Jun 19 '17 at 06:13
  • I think you need to post few lines of code above this condition so that it will be useful to help – manian Jun 19 '17 at 06:16

4 Answers4

2
header("Location: singleprod.php?product_id=".$row['product_id']);

use this instead

Exprator
  • 26,992
  • 6
  • 47
  • 59
0

Try this

header("location:singleprod.php?product_id=".$row['product_id'].");
Sehdev
  • 5,486
  • 3
  • 11
  • 34
0
if (!$result_insert_user){
    echo 'Query Failed ';
}else{
    header("location:single_prod.php?product_id=".$row['product_‌​id']);
}

Use above code.

Ankit Singh
  • 1,477
  • 1
  • 13
  • 22
-1

Just add a space after colon (:)

header("Location: singleprod.php?product_id=$row['product_id']");

Update: why the downvote? I didn't type full url because I answered using mobile.

yetanotherse
  • 500
  • 3
  • 16