Solved

simplexml issues

Posted on 2008-10-28
22
826 Views
Last Modified: 2012-05-05
im created a small script to gather browser data for a site.  im using PHP5 and SimpleXML.

if i view:  http://www.antons-law.com/properties2/browser-stats.php  it works fine, displays blank page (as page will be executed in the background) and saves your browser name, version etc in an XML file.

however if i try include my browser-stats.php page in another file, say index.php i get the following error:

Fatal error: Call to undefined function: simplexml_load_file() in /home/ukpegasu/public_html/antons-law/properties2/browser-stats.php on line 10

I dont understand what is wrong or why is brakes...?  please help.
index.php
=====================
<?php
include_once('browser-stats.php');
?>
 
browser-stats.php
=====================
 
<?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)
{
	$attributes = $entries[0]->attributes(); 
	$attributes->users = $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');
?>
 
browser-stats.xml
===============================
 
http://www.antons-law.com/properties2/browser-stats.xml

Open in new window

0
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 10
22 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22821206
What version of PHP are you running?

Also, (off topic) you might want to look at this page in Firefox - the navigation is broken on "Properties"
http://www.antons-law.com/

0
 
LVL 16

Author Comment

by:ellandrd
ID: 22821230
im using PHP5.  

Yes i know.  i've still to redesign that side of the site.  but first i need to get the properties side of things working first....  ;-)
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22821242
Sorry - I read too fast - PHP5.

Simple XML should be there by default: http://us.php.net/manual/en/simplexml.installation.php

I'll do a little more digging! ~Ray

0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 16

Author Comment

by:ellandrd
ID: 22821291
Yes I know. Both the local server  and live server have PHP5.  All works fine locally but as soon as i FTP, it dies...

Im also looking at the documentation incase i see any clues but nothing yet!
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22821301
Run this on the server and post the (painfully lengthy) output!
<?php phpinfo(); ?>

Open in new window

0
 
LVL 16

Author Comment

by:ellandrd
ID: 22821342
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 350 total points
ID: 22821432
Thanks - can't see anything wrong there.  Have you raised this with BlueHost?  Their support is usually pretty good.

Also, can you post the code for these scripts so I can install on my server?  I will be glad to make a mirror test for you.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22821497
Attached my files... rename .txt to .php  (EE wont allow .php or a ZIP file containing .php)  HOPE YOUR READING THIS EE PROGRAMMERS - VERY ANNOYING!

You got Browscap enabled?  If not then just use dummy data for browser name, version.... you'll see what i mean!

btw, i've just changed my script to use:

$xmlobj = new SimpleXMLElement($xmlstring);

and still no luck!
ellandrd.zip
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22821511
Looking at this message...

Fatal error: Call to undefined function: simplexml_load_file() in /home/ukpegasu/public_html/antons-law/properties2/index.html on line 13

I wonder if there is something about parsing PHP at issue here.  Could the include statement somehow be looking at an older version of PHP or a different library?
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22821557
Mmmm.  Ray you might be right.  I'm just looking at the error logs and this is what i get:

However If i look in my php.ini file (unedited and provided to me by bluehosts) i dont have the extension php_domxml.dll uncommented so it shouldnt be working...right?

in my cPanel on bluehost i can see the PHP version enabled and it shows PHP 5.5.6..... i have PHP5.5.6 installed locally too.
[28-Oct-2008 07:12:16] PHP Warning:  Unknown(): Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:12:16] PHP Fatal error:  Call to undefined function:  simplexml_load_file() in /home/ukpegasu/public_html/antons-law/properties2/index.html on line 13
[28-Oct-2008 07:13:10] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:13:11] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:13:11] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:15:28] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:15:28] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:15:28] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:18:06] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:18:07] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:18:07] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:24:17] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:24:17] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:24:18] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:27:03] PHP Warning:  Unknown(): Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:27:03] PHP Fatal error:  Call to undefined function:  simplexml_load_file() in /home/ukpegasu/public_html/antons-law/properties2/index.html on line 13
[28-Oct-2008 07:29:18] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:29:18] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0
[28-Oct-2008 07:29:18] PHP Warning:  PHP Startup: Unable to load dynamic library './php_domxml.dll' - ./php_domxml.dll: cannot open shared object file: No such file or directory in Unknown on line 0

Open in new window

0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 350 total points
ID: 22821645
Make sure your error_log is not full and set error_reporting(E_ALL) - you can sprinkle in some var_dump() statements and it's worth testing the return from all your functions.

In unrelated news, you can post PHP files in to the code snippet.  Normally I avoid opening any zip files - at least from unfamiliar posters!
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22821667
That helps.  Seeing the log, I'd say the next step is here:
http://helpdesk.bluehost.com/help

0
 
LVL 16

Author Comment

by:ellandrd
ID: 22821689
>>In unrelated news, you can post PHP files in to the code snippet.  

As i said EE wont allow me post the .php file extension so you will have to copy and paste my code from above then.

>>Normally I avoid opening any zip files - at least from unfamiliar posters!

cant argue with that....
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22821969
Yeah, I understand about the PHP file extension.  Seems like it could be automatically converted to something unparseable like .phpFIleText, eh!
0
 
LVL 3

Assisted Solution

by:DarkFish
DarkFish earned 150 total points
ID: 22822008
Well, firstly you're on a Linux box so a .dll will not work. You would need to use the Linux equivalent of the dll; however in this case you shouldn't need to.

On BlueHost the domxml ext. is compiled into PHP; you don't need the extension=php_domxml.dll in your php.ini.

Try commenting it out and see if your script works, which it should. :)
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22822104
DarkFish

I ahve already mentioned that i do not have this line commented in.  The PHP.ini file that i was given by bluehost has not been changed.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22822162
im chatting live to bluehost support but getting no where....  why do they hire guys to support PHP when the guys have no idea.....
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22822173
Because they're cheap.  Tell them to escalate the problem - don't waste time with the phone jockeys.
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22822192
now they have replaced my default php.ini file with a new one which has broken the php_browscap.ini file......
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22822208
Can you tell me more about browscap? Or post the code?
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22822299
Nevermind - for some reason I have never seen get_browser() D'OH>
0
 
LVL 16

Author Comment

by:ellandrd
ID: 22822312
browscap is just a database containing browser info.

http://uk2.php.net/get_browser
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
This article discusses how to create an extensible mechanism for linked drop downs.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

739 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