#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    Smile Help with PHP feed im working on plz?


    Hi,

    I'm hoping to get a little bit of help with regards to an ASP script that I have translated into PHP.

    The ASP code is basically a health feed that scrapes it content from an external source and processes this scrape and outputs it onto a page of a website.

    The ASP version of the code is as follows:

    go to paste bin and add this to end of url: p5EtSMzR

    This asp code is working and has been implemented many times.

    The PHP version of the code is as follows:

    go to paste bin and add this to end of url: EkQFCf8B

    This php code is not working and I am really stuck and need assistance to get it to work.

    The ASP code would be added to a page called feed-page.asp which would be referenced in a HTML file in order to it to be linked to via links within that HTML page.

    Here is an example of a test HTML page which I have tried to implement the PHP Version:

    go to paste bin and add this to end of url: Xu2VnXZm


    the span buttons in the middle of the html page are supposed to link to the relevant sections on the feed page. I have removed the links because i couldnt get them to work

    can anyone help?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,967
    Rep Power
    374
    q 1: $xml = file_get_contents("MSXML2.ServerXMLHTTP"); ?? shouldnt this be:

    $xml = file_get_contents($url);?

    fix this first and then let us know if it has worked
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0
    here is the newer code, with the suggestion from yourself added:

    pastebindotcom/8ATx0sgS

    ive also got some php errors:

    Notice: Undefined index: page in nhs-feed.php on line 3

    (nhs-feed.php is the file name for the php code above)

    Also, when i go to the feed-page, i get an output error that is echo'd in the php code:

    Warning: file_get_contents(thenhsurlfrommyscript): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in
    nhs-feed.php on line 12

    Sorry, the current NHS choices content is not available at this time.


    --

    my apologies for having to cut out the urls in the errors, it wont let me post urls here
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    Please post your code here, that is what this forum is for. Please read the sticky at the top of this forum that says READ THIS BEFORE POSTING.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0
    How can i post my php code using the php tags when my code contains a few key URLS - which i am not allowed to post because im a new user?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    Since URLs are just strings as far as the formatter is concerned, it will let you post them within PHP tags. However, I'd advise, for security reasons, you sanitize those URLs.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,547
    Rep Power
    2337
    If this is an RSS feed, you might consider using MagpieRSS instead of your error-prone parsing scheme.

    PHP Code:
    $page=$_GET["page"]; 
    If there's no page variable in the URL, you're going to get that notice. Passing a page variable via a url is done like this:

    PHP Code:
    http://www.example.com/myurl.php?page=4 
    You could try this

    PHP Code:
    $page = (isset($_GET['page']) ? $_GET['page'] : 1); 
    which will set the page from the URL if it's there, or set the value to 1.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,967
    Rep Power
    374
    [QUOTE=GnomeSmasher]
    Also, when i go to the feed-page, i get an output error that is echo'd in the php code:

    Warning: file_get_contents(thenhsurlfrommyscript): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in
    nhs-feed.php on line 12
    /QUOTE]

    this is your problem right there, just to test this i would just insert a proper URL

    like file_get_content("http://.....");

    and see what happens, make sure the rest of the script onwards work properly.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    ok


    right, ive made some changes, hopefully they are good changes ...as you suggested paul.

    here is the new code:

    pastebin_dot_com/gNRVGYt0

    i now get the error:

    Fatal error: Call to undefined function _instr() in nhs-feed.php on line 35


    im a bit stuck

    but at least it is getting further down the script before it errors

IMN logo majestic logo threadwatch logo seochat tools logo