Page 1 of 1

domdocument() expects parameter 2 to be long, string given..

Posted: Sun May 17, 2009 9:37 am
by kimberly
Hi all,

I am new to PHP.

After much pain and suffering, :banghead:
I finally got my code working locally! but it doesnt work when I upload it to the server.

This line of code:
$doc = new DomDocument('1.0', 'UTF-8');

causes this error:
domdocument() expects parameter 2 to be long, string given in.....

I'm worried it's got to do with the PHP versions?
local: PHP Version 5.2.9-1
server: PHP Version 4.4.4-8+etch6

As it's a shared server, I dont think I'll be able to change any settings on the server.

Any help will be greatly appreciated.

regards,
Kimberly

Re: domdocument() expects parameter 2 to be long, string given..

Posted: Sun May 17, 2009 9:49 am
by Benjamin
According to the manual, the second parameter should be a string. See: http://us3.php.net/manual/en/domdocument.construct.php

Re: domdocument() expects parameter 2 to be long, string given..

Posted: Sun May 17, 2009 9:58 am
by Darhazer
astions wrote:According to the manual, the second parameter should be a string. See: http://us3.php.net/manual/en/domdocument.construct.php
This is for PHP 5, and he tries to run on PHP 4 server, with the old DOM extension.

kimberly - ask your hosting if they support PHP 5 - usually shared hosting have both PHP 4 and 5 installed and the version can be switched. PHP 4 is not supported by the PHP Group, it is really old, so if your hosting do not support version 5, maybe you should think about switching the hosting provider?

Re: domdocument() expects parameter 2 to be long, string given..

Posted: Sun May 17, 2009 10:01 am
by Benjamin
Darhazer wrote:This is for PHP 5, and he tries to run on PHP 4 server, with the old DOM extension.
Ah ok :? - I didn't realize they were now changing parameter types in function calls.

Re: domdocument() expects parameter 2 to be long, string given..

Posted: Sun May 17, 2009 10:24 am
by kimberly
Thanks very much!
I will ask them if they support PHP5.
Based on your response, It seems like a reasonable request.

Many thanks!

cheers,
Kimberly

Re: domdocument() expects parameter 2 to be long, string given..

Posted: Mon May 18, 2009 3:17 pm
by kimberly
Hi again,

the hosting service will upgrade to PHP5 but then it will require that we test the whole site for compatibility on PHP5.
I'd like to avoid this if possible.

I asked if they could uncomment this line in the php.ini: extension=php_domxml.dll
but they say no because: "we are hosted on a Linux server and therefore cannot support DLL extensions. Also we do
not add/change extensions/applications for shared servers."

Can I use something else similar to domxml and DomDocument which will work on PHP4?

thanks again,
Kimberly

Re: domdocument() expects parameter 2 to be long, string given..

Posted: Tue May 19, 2009 3:23 pm
by Darhazer
You can use the PHP 4 DomXML, which is quite different from the PHP 5 one
http://php.net/manual/en/book.domxml.php

Re: domdocument() expects parameter 2 to be long, string given..

Posted: Wed May 20, 2009 3:01 am
by kimberly
Thanks very much!
I will try that!