Solved

simplexml issues

Posted on 2008-10-28
22
809 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
  • 11
  • 10
22 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
 
LVL 16

Author Comment

by:ellandrd
Comment Utility
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 108

Expert Comment

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

Open in new window

0
 
LVL 16

Author Comment

by:ellandrd
Comment Utility
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 350 total points
Comment Utility
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
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 350 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
>>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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
now they have replaced my default php.ini file with a new one which has broken the php_browscap.ini file......
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Can you tell me more about browscap? Or post the code?
0
 
LVL 108

Expert Comment

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

Author Comment

by:ellandrd
Comment Utility
browscap is just a database containing browser info.

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

763 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

11 Experts available now in Live!

Get 1:1 Help Now