Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with readfile code

    Here is my problem: I have a tv broadcast server that can display my tv schedule using it's built in server. I would like to display my schedule on my own website using my header and everything.

    My server uses query strings to display the requested schedule. An example is http://example.com/ websched.php?channel=1&mode=week&headers=1

    I use readfile('http://www.example.com/text.txt'); to display a song that is "now playing" on my radio station's website and it works fine. But it's the query strings that mess up the php request when trying to use it on my tv server.

    Can someone please help me in figuring this out. Thanks!

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    428
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Are you using readfile() on a local file or a remote website? I'm not sure if you can readfile() a website page.

    Try file_get_contents and() and echo it to see if that returns the correct data, then you'll know whether or not its you or the other site.

  • #3
    New to the CF scene
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think the problem is that i'm trying to use a port number. Is there any way i can set different strings and have it parse it together?

    I'm not fluent in PHP. :/

    something like:

    <?php

    $hostname = "addresshere.com";
    $port = "50001";
    $path = "websched.php";
    $arg1 = "channel";
    $value1 = "1";
    $arg2 = "mode";
    $value2 = "week";
    $arg3 = "headers";
    $value3 = "1";

    $url = 'http://hostnameort/path?arg1=value1&arg2=value2&arg3=value3';

    echo parse_url($url);
    ?>



    Quote Originally Posted by Dubz View Post
    Are you using readfile() on a local file or a remote website? I'm not sure if you can readfile() a website page.

    Try file_get_contents and() and echo it to see if that returns the correct data, then you'll know whether or not its you or the other site.

  • #4
    Regular Coder
    Join Date
    Sep 2011
    Posts
    428
    Thanks
    18
    Thanked 26 Times in 26 Posts
    look at http_build_query(); to see a more proper way of doing this. I don't know if you're using parse_url() to see what it got out of it or if that's your way of encoding it, but http_build_query() will be better to use either way.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •