How to put variable in JSON URL? [closed]












-2














Tried a lot of combinations but nothing works.



$json = file_get_contents("http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=$artist");









share|improve this 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
















-2














Tried a lot of combinations but nothing works.



$json = file_get_contents("http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=$artist");









share|improve this 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














-2












-2








-2


1





Tried a lot of combinations but nothing works.



$json = file_get_contents("http://www.theaudiodb.com/api/v1/json/58424d43204d6564696120/search.php?s=$artist");









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












1 Answer
1






active

oldest

votes


















1














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





share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














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





    share|improve this answer




























      1














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





      share|improve this answer


























        1












        1








        1






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





        share|improve this answer














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






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 12 '18 at 22:07

























        answered Nov 12 '18 at 22:02









        PhilPhil

        96.1k11136156




        96.1k11136156















            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma