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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kimberly
Forum Commoner
Posts: 31
Joined: Tue Apr 21, 2009 12:48 pm

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

Post 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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

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

Post by Benjamin »

According to the manual, the second parameter should be a string. See: http://us3.php.net/manual/en/domdocument.construct.php
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

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

Post 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?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

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

Post 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.
kimberly
Forum Commoner
Posts: 31
Joined: Tue Apr 21, 2009 12:48 pm

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

Post 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
kimberly
Forum Commoner
Posts: 31
Joined: Tue Apr 21, 2009 12:48 pm

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

Post 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
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

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

Post 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
kimberly
Forum Commoner
Posts: 31
Joined: Tue Apr 21, 2009 12:48 pm

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

Post by kimberly »

Thanks very much!
I will try that!
Post Reply