Page 1 of 1

$xsltproc=xslt_create() - help please!

Posted: Thu Dec 18, 2008 11:21 am
by hippyju
Hi there, I'm now to this forum. I cannot get this piece of PHP code to work. Basically, the PHP code detects which browser the user is using, and then display the XML file and an XSL stylesheet depending on the browser they are using - but it doesn't work! Although echo ("<h3>IE</h3>"); and the other 2 work does work, nothing else does. Hope you can help. Thanks, Julie.

<html>
<head><title>Determining Browser Type</title></head>
<body>
<h1>Determining Browser Type</h1>
<br />
<?php
if(substr_count($_SERVER["HTTP_USER_AGENT"], "MSIE") > 0){
echo ("<h3>IE</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','IE.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
else if(substr_count($_SERVER["HTTP_USER_AGENT"], "Opera") > 0){
echo ("<h3>Opera</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','Opera.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
else if(substr_count($_SERVER["HTTP_USER_AGENT"], "Firefox") > 0){
echo ("<h3>firefox</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','Firefox.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
?>
</body>
</html>

Re: $xsltproc=xslt_create() - help please!

Posted: Thu Dec 18, 2008 1:40 pm
by syth04
hippyju wrote:Hi there, I'm now to this forum. I cannot get this piece of PHP code to work. Basically, the PHP code detects which browser the user is using, and then display the XML file and an XSL stylesheet depending on the browser they are using - but it doesn't work! Although echo ("<h3>IE</h3>"); and the other 2 work does work, nothing else does. Hope you can help. Thanks, Julie.

<html>
<head><title>Determining Browser Type</title></head>
<body>
<h1>Determining Browser Type</h1>
<br />
<?php
if(substr_count($_SERVER["HTTP_USER_AGENT"], "MSIE") > 0){
echo ("<h3>IE</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','IE.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
else if(substr_count($_SERVER["HTTP_USER_AGENT"], "Opera") > 0){
echo ("<h3>Opera</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','Opera.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
else if(substr_count($_SERVER["HTTP_USER_AGENT"], "Firefox") > 0){
echo ("<h3>firefox</h3>");
$xsltproc=xslt_create();
$xslt_result = xslt_process($xsltproc,'uk.xml','Firefox.xsl');
echo $xslt_result;
xslt_free($xsltproc);
}
?>
</body>
</html>
Do you have error handling enabled?

I tried running your code, and I received this

Code: Select all

Determining Browser Type
 
firefox
 
Fatal error: Call to undefined function xslt_create() in /home/www/public_html/quote/test/index.php on line 24
 
Which means I do not have the function installed in my php server