-1

I have searched many previous posts here, and nothing seems to work with my issue. In a nutshell, I am looking to include a PHP variable in the following code. This code below works as it is hardcoded, but I get an error when I replace the word MAYIAHH with a variable $hid (which has been declared).

I have tried CURLOPT_POSTFIELDS and all sorts, but nothing seems to help. Any ideas, please?

function send_request($xml)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 
        'https://rest.reserve-online.net/availability?properties=MAYIAHH');
    curl_setopt($ch, CURLOPT_USERPWD, "uname:pass");
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    curl_close($ch);
    
    return $result;
}
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
  • Does this answer your question? [What is the difference between single-quoted and double-quoted strings in PHP?](https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – Luuk Apr 25 '22 at 16:37

1 Answers1

0

Have you tried to concat the url string?

$hid = 'MAYIAHH';
$url = 'https://rest.reserve-online.net/availability?properties='.$hid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "uname:pass");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
Voxxii
  • 369
  • 2
  • 9