0

these lines of code work fine on my localhost, but not on my VPS hosting:

$url = "http://gdata.youtube.com/feeds/api/videos/".$videoID;
$doc = new DOMDocument;
$doc->load($url);
$title = $doc->getElementsByTagName("title")->item(0)->nodeValue; 
$description = $doc->getElementsByTagName("description")->item(0)->nodeValue;

I can't figure out why they would work on localhost and not my vps which is set up like the exact same as localhost.

9
  • 2
    Your VPS either has a different version of PHP (potentially < version 5) or DomDocument extension was disabled when your PHP was compiled. Commented Feb 15, 2012 at 5:28
  • 1
    What's the actual error? Commented Feb 15, 2012 at 5:29
  • it has 5.3.3 installed.my localhost has 5.3.6 Commented Feb 15, 2012 at 5:29
  • 2
    Please define "doesn't work". What does or doesn't it do? Commented Feb 15, 2012 at 5:29
  • No error shows, it just stops everything beyond that part of the script from working. Commented Feb 15, 2012 at 5:32

1 Answer 1

2

http://199.192.203.137/phpinfo.php

DOM is explicitly disabled there: --disable-dom.

Either contact your host and ask them to enable DOM (unlikely), use a different host or rewrite your code using another DOM/XML library.

Sign up to request clarification or add additional context in comments.

3 Comments

What are the reasons why it would be disabled? What security things could be involved?
@DylanCross not necessarily security issue, you should ask your hosting provider provide you with the DOM enabled php binary, or do it yourself.
@Dylan Some hosts just don't want to deal with too many dependencies and only support the bare minimum configuration, others do it because "that's what most people use", others have no good reasons at all. Talk to your host.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.