0

I am having trouble with following code

$res=mysqli_fetch_array($value);
header("location:home.php?result=$res");

This is not working! The url seems to be home.php?result=Array. How can I pass the array $res without using session?

Rasclatt
  • 12,498
  • 3
  • 25
  • 33

2 Answers2

2

You should first generate URL-encoded query string using http_build_query:

$res=mysqli_fetch_array($value);
$res = http_build_query($res);
header("location:home.php?result=$res");
T. AKROUT
  • 1,719
  • 8
  • 18
0

You can prefer http_build_query() function to encode in string and then send to querystring

$res=mysqli_fetch_array($value);
header("location:home.php?result=".http_build_query($res));

Have a look an example for that

 <?php

    $data = array('email' => 'test@test.com',
        array("php", "mysql"),
        'age' => 28);
    echo 'page2.php?' . http_build_query($data);
    //output: page2.php?email=test%40test.com&0%5B0%5D=php&0%5B1%5D=mysql&age=28
    ?>