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?
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?
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");
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
?>