Solved

domdocument expects parameter 2 to be long, string given

Posted on 2008-10-27
8
1,193 Views
Last Modified: 2008-11-01
Warning: domdocument() expects parameter 2 to be long, string given in browser-stats.php on line 10

Fatal error: Call to undefined function: load() in browser-stats.php on line 11

PHP Version 4.4.9, domxml enabled
$doc = new DOMDocument('1.0', 'iso-8859-1');

$doc->load('browser-stats.xml');

Open in new window

0
Comment
Question by:ellandrd
  • 5
  • 2
8 Comments
 
LVL 6

Expert Comment

by:cr4ck3rj4ck
ID: 22812469
Seen this problem around before.

The problem lies in your php.ini file which most likely loads the php_domxml.dll. PHP5 comes default with the DOM extention enabled. php_domxml is for PHP4 and should be commented.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22812491
im not using PHP5.  im using PHP4.4.9.  been searching for solution all morning and still nothing will work regardless of what i try
0
 
LVL 10

Expert Comment

by:MadShiva
ID: 22812545
Hi !

This function need php 5.

You can use DOM XML : http://www.php.net/domxml

Best Regards
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22812773
arent i using dom xml??
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Expert Comment

by:MadShiva
ID: 22813256
Hi !

Sorry, forget that I have say.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22814094
ok can somebody point me to some XML examples too:

create new node
update attribute value

in PHP5?
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22816471
ok i have been trying to get mu page working in PHP5 using SimpleXML.

however i cant seem to add a new node.

my XML file looks like this:

<?xml version="1.0"?>
<browsers>
      <browser name="Firefox" version="3.0" platform="WinXP" users="46"/>
</browsers>

I want to add a new browser node so my XML file would look like this:

<?xml version="1.0"?>
<browsers>      
      <browser name="Firefox" version="3.0" platform="WinXP" users="46"/>
        <browser name="Opera" version="9.2" platform="WinXP" users="1"/>
</browsers>
<?php

$xmlobj = simplexml_load_file('browser-stats.xml');
 

$browser = $xmlobj->addChild('browser');

$browser->addAttribute('name','Opera');
 

$xmlobj->asXML('browser-stats.xml');

?>

Open in new window

0
 
LVL 16

Accepted Solution

by:
ellandrd earned 0 total points
ID: 22816905
ok i got it working after some struggle but who gets it right first time??


<?php

$browser = array();

$browser = get_browser(null, true);
 

$name = $browser['browser'];

$version = $browser['version'];

$platform = $browser['platform'];

$users = 1;
 

$xmlobj = simplexml_load_file('browser-stats.xml');
 

$query = '/browsers/browser[@name="'.$name.'"][@version="'.$version.'"][@platform="'.$platform.'"]';
 

$entries = $xmlobj->xpath($query);
 

if(count($entries) == 1)

{

	$entries[0]->attributes()->users = $entries[0]->attributes()->users + 1;

}

else

{

	$browserobj = $xmlobj->addChild('browser');

	$browserobj->addAttribute('name',$name);

	$browserobj->addAttribute('version',$version);

	$browserobj->addAttribute('platform',$platform);

	$browserobj->addAttribute('users',$users);

}
 

$xmlobj->asXML('browser-stats.xml');

?>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now