How to put variable in JSON URL? [closed]
Tried a lot of combinations but nothing works.
$json = file_get_contents("http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=$artist");
php
closed as unclear what you're asking by Progman, Jeto, fubar, Alon Eitan, Don't Panic Nov 12 '18 at 22:29
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
Tried a lot of combinations but nothing works.
$json = file_get_contents("http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=$artist");
php
closed as unclear what you're asking by Progman, Jeto, fubar, Alon Eitan, Don't Panic Nov 12 '18 at 22:29
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
4
What doesn't work?
– fubar
Nov 12 '18 at 21:52
For debugging purposes: Save the URL in a variable first and output it. Check that the URL is correct. After that edit your question to include the full source code you have and the error message you get.
– Progman
Nov 12 '18 at 21:53
the variable i don't know how to place the variable $artist
– phobos9570
Nov 12 '18 at 21:54
1
Looks fine to me. The only other thing I'd do is make sure it's encoded correctly for use in a URL, ie...search.php?s=" . urlencode($artist)
– Phil
Nov 12 '18 at 21:57
Thanks it works!
– phobos9570
Nov 12 '18 at 22:00
add a comment |
Tried a lot of combinations but nothing works.
$json = file_get_contents("http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=$artist");
php
Tried a lot of combinations but nothing works.
$json = file_get_contents("http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=$artist");
php
php
edited Nov 12 '18 at 21:53
jonrsharpe
76.9k11102208
76.9k11102208
asked Nov 12 '18 at 21:50
phobos9570phobos9570
84
84
closed as unclear what you're asking by Progman, Jeto, fubar, Alon Eitan, Don't Panic Nov 12 '18 at 22:29
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Progman, Jeto, fubar, Alon Eitan, Don't Panic Nov 12 '18 at 22:29
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
4
What doesn't work?
– fubar
Nov 12 '18 at 21:52
For debugging purposes: Save the URL in a variable first and output it. Check that the URL is correct. After that edit your question to include the full source code you have and the error message you get.
– Progman
Nov 12 '18 at 21:53
the variable i don't know how to place the variable $artist
– phobos9570
Nov 12 '18 at 21:54
1
Looks fine to me. The only other thing I'd do is make sure it's encoded correctly for use in a URL, ie...search.php?s=" . urlencode($artist)
– Phil
Nov 12 '18 at 21:57
Thanks it works!
– phobos9570
Nov 12 '18 at 22:00
add a comment |
4
What doesn't work?
– fubar
Nov 12 '18 at 21:52
For debugging purposes: Save the URL in a variable first and output it. Check that the URL is correct. After that edit your question to include the full source code you have and the error message you get.
– Progman
Nov 12 '18 at 21:53
the variable i don't know how to place the variable $artist
– phobos9570
Nov 12 '18 at 21:54
1
Looks fine to me. The only other thing I'd do is make sure it's encoded correctly for use in a URL, ie...search.php?s=" . urlencode($artist)
– Phil
Nov 12 '18 at 21:57
Thanks it works!
– phobos9570
Nov 12 '18 at 22:00
4
4
What doesn't work?
– fubar
Nov 12 '18 at 21:52
What doesn't work?
– fubar
Nov 12 '18 at 21:52
For debugging purposes: Save the URL in a variable first and output it. Check that the URL is correct. After that edit your question to include the full source code you have and the error message you get.
– Progman
Nov 12 '18 at 21:53
For debugging purposes: Save the URL in a variable first and output it. Check that the URL is correct. After that edit your question to include the full source code you have and the error message you get.
– Progman
Nov 12 '18 at 21:53
the variable i don't know how to place the variable $artist
– phobos9570
Nov 12 '18 at 21:54
the variable i don't know how to place the variable $artist
– phobos9570
Nov 12 '18 at 21:54
1
1
Looks fine to me. The only other thing I'd do is make sure it's encoded correctly for use in a URL, ie
...search.php?s=" . urlencode($artist)
– Phil
Nov 12 '18 at 21:57
Looks fine to me. The only other thing I'd do is make sure it's encoded correctly for use in a URL, ie
...search.php?s=" . urlencode($artist)
– Phil
Nov 12 '18 at 21:57
Thanks it works!
– phobos9570
Nov 12 '18 at 22:00
Thanks it works!
– phobos9570
Nov 12 '18 at 22:00
add a comment |
1 Answer
1
active
oldest
votes
The only thing I can think of that wouldn't "work" is if the $artist
variable contained characters not suitable for use in a URL (like spaces, punctuation, etc).
PHP has a function that can make strings safe for use in a URL ~ urlencode()
...
$artist = 'Pink Floyd'; // spaces should be encoded as "%20" or "+"
$json = file_get_contents(sprintf(
'http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=%s',
urlencode($artist)));
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The only thing I can think of that wouldn't "work" is if the $artist
variable contained characters not suitable for use in a URL (like spaces, punctuation, etc).
PHP has a function that can make strings safe for use in a URL ~ urlencode()
...
$artist = 'Pink Floyd'; // spaces should be encoded as "%20" or "+"
$json = file_get_contents(sprintf(
'http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=%s',
urlencode($artist)));
add a comment |
The only thing I can think of that wouldn't "work" is if the $artist
variable contained characters not suitable for use in a URL (like spaces, punctuation, etc).
PHP has a function that can make strings safe for use in a URL ~ urlencode()
...
$artist = 'Pink Floyd'; // spaces should be encoded as "%20" or "+"
$json = file_get_contents(sprintf(
'http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=%s',
urlencode($artist)));
add a comment |
The only thing I can think of that wouldn't "work" is if the $artist
variable contained characters not suitable for use in a URL (like spaces, punctuation, etc).
PHP has a function that can make strings safe for use in a URL ~ urlencode()
...
$artist = 'Pink Floyd'; // spaces should be encoded as "%20" or "+"
$json = file_get_contents(sprintf(
'http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=%s',
urlencode($artist)));
The only thing I can think of that wouldn't "work" is if the $artist
variable contained characters not suitable for use in a URL (like spaces, punctuation, etc).
PHP has a function that can make strings safe for use in a URL ~ urlencode()
...
$artist = 'Pink Floyd'; // spaces should be encoded as "%20" or "+"
$json = file_get_contents(sprintf(
'http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=%s',
urlencode($artist)));
edited Nov 12 '18 at 22:07
answered Nov 12 '18 at 22:02
PhilPhil
96.1k11136156
96.1k11136156
add a comment |
add a comment |
4
What doesn't work?
– fubar
Nov 12 '18 at 21:52
For debugging purposes: Save the URL in a variable first and output it. Check that the URL is correct. After that edit your question to include the full source code you have and the error message you get.
– Progman
Nov 12 '18 at 21:53
the variable i don't know how to place the variable $artist
– phobos9570
Nov 12 '18 at 21:54
1
Looks fine to me. The only other thing I'd do is make sure it's encoded correctly for use in a URL, ie
...search.php?s=" . urlencode($artist)
– Phil
Nov 12 '18 at 21:57
Thanks it works!
– phobos9570
Nov 12 '18 at 22:00