#Edp425
1 messages · Page 1 of 1 (latest)
Hi
hello! gimme a couple of minutes to get back to you
Thanks
the query expects a string so you would look into how to concatenate variables in a string in PHP e.g. https://www.php.net/manual/en/language.operators.string.php
Your string is formatted wrongly. You can see a example here : https://stripe.com/docs/api/subscriptions/search - select php from the sample code
Example
$stripe->subscriptions->search([
'query' => 'status:\'active\' AND metadata[\'order_id\']:\'6735\'',
]);```
yes but my order id is a variable
so $stripe->subscriptions->search([
'query' => 'status:'active' AND metadata['order_id']:'$howdoiputvariablehere'',
]);
To clarify, this
'status:'active' AND metadata['order_id']:'$howdoiputvariablehere'' isn't a proper string
to include single quotes in the string, you need to prefix with a slash
$log= $stripe->subscriptions->search([
'query' => 'status: "active" AND metadata['customerid']: '$test' ',
]);
it wont let me add the slash on dc
but i need to search by variable
to include code in discord, start and end with 3 backticks
since you're aware of how to format the string, go ahead and try it out
but i don't know how to add a variable
how do i concentrate the variable into the string
'query' => 'status:\'active\' AND metadata[\'customerid\']:\'{$myvariablehere}\'',
]);
the {} is not workign 😦
to give you an example
$varhere = 'hello';
$longstring = "status:\'active\' AND metadata[\'order_id\']:\'{$varhere}\'";
echo $longstring;
ty bro "" worked
it was the speechmarks
still getting an error though 1 sec
but i am trying to add it in that stripe query
what's the error?
the variable doesn't work
'query' => "status:\'active\' AND metadata[\'customerid\']:\'{$testvariable}\'",
]);
echo $log;
why aren't you using double quotes to enclose the string?
like the documentation mentions : https://www.php.net/manual/en/language.operators.string.php
Remember to use double quotes (" ") as their content is parsed by php, because in single quotes (' ') you'll get literal name of variable provided:
Ensure you have properly quoted values while searching. Try updating your query to status:"\'active\'" at line 1 and column 8. thrown in C:\xampp\htdocs\myfans3\vendor\stripe\stripe-php\lib\Exception\ApiErrorException.php on line 38
but at least the variable is blue in double quotes
onesec, looking into this
yeah, it was driving me up the wall too 🤣
this should work
$longstring = "status:'active' AND metadata['order_id']:'" . $varhere ."'";
echo $longstring;
$result = $stripe->subscriptions->search([
'query' => $longstring,
]);
if you enclose it with double quotes, you don't need the slash for the single quotes
so this works too
$result = $stripe->subscriptions->search([
'query' => "status:'active' AND metadata['order_id']:'{$varhere}'",
]);