Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error on PHP file, not sure what to do

Status
Not open for further replies.

timhersh

Programmer
Mar 10, 2012
1
US
I took over a wordpress website and thought everything was pretty simple. I downloaded all the files and uploaded it and everything worked great..until I realized there was a section on this site I wasn't aware of.

The site has a product section that lists all types of products. It is not working, nothing show up at all.

I researched it the best I could and discovered that if I navigate to a specific file on the website it gives me an error message. I'm thinking this might be the problem with why the site is not working. All I did was change the hosting company.

The main problem is that I am good with most tasks in PHP but this is involving XML and I am not sure how XML scripts work.

Here is the error:

Fatal error: Call to a member function getElementsByTagName() on a non-object in /home/image/public_html/indoorcomfortteam.com/wp-content/themes/indoorcomfortteam/inc/product-top.php on line 77

Here is the code for that file. line 77 says this

<?php

if($pagetype=="list"){

$objDOM = new DOMDocument();
$objDOM->load("/home/image/public_html/indoorcomfortteam.com/wp-
content/themes/indoorcomfortteam/products.xml");

$xpathMain = new DOMXPath($objDOM);
$query = "//products/product[id='".$_GET["id"]."']";
$product = $xpathMain->query($query)->item(0);
$title = $product->getElementsByTagName("title")->item(0)->nodeValue;
$descr = $product->getElementsByTagName("descr")->item(0)->nodeValue;
$img = $product->getElementsByTagName("img")->item(0)->nodeValue;
$logoimg = $product->getElementsByTagName("logoimg")->item(0)->nodeValue;

if ($contentwidth==""){
$contentwidth = "650";
}
$loopcount = 4;
if($product->getElementsByTagName("types")->item(0)){
$prelimtypecnt = $product->getElementsByTagName("types")->length;
$typecount = $product->getElementsByTagName("types")->item(0)-
>getElementsByTagName("type")->length;
if ($typecount>4){
$typewidth = ($contentwidth/4)."px";
$typeholderheight = "300px";
$typeheight = "150px";

}
else{
$typewidth = ($contentwidth/$typecount)."px";
$typeholderheight = "150px";
$typeheight = "150px";
}
} else {
$typecount = 0;
}
if ($_GET["id"]=="GS" || $_GET["mainid"]=="GS"){
$typewidth = ($contentwidth/3)."px";
$typeholderheight = "160px";
$typeheight = "80px";
$loopcount = 3;
}
if ($_GET["id"]=="AH" || $_GET["mainid"]=="AH"){
$typewidth = ($contentwidth/3)."px";
$typeholderheight = "300px";
$typeheight = "150px";
$loopcount = 3;
}
if ($_GET["id"]=="HUM" || $_GET["mainid"]=="HUM"){
$typewidth = ($contentwidth/2)."px";
$typeholderheight = "300px";
$typeheight = "150px";
$loopcount = 2;
}
if ($_GET["id"]=="TMS" || $_GET["mainid"]=="TMS"){
$typewidth = ($contentwidth/2)."px";
$typeholderheight = "440px";
$typeheight = "220px";
$loopcount = 2;
}
if ($_GET["id"]=="FUR" || $_GET["mainid"]=="FUR"){
$typewidth = ($contentwidth/4)."px";
$typeholderheight = "340px";
$typeheight = "170px";
$loopcount = 4;
}
}
else{

$objDOM = new DOMDocument();
$objDOM->load("/home/image/public_html/indoorcomfortteam.com/wp-
content/themes/indoorcomfortteam/products.xml");

$xpathMain = new DOMXPath($objDOM);
$query = "//products/product[id='".$_GET["mainid"]."']";
$product = $xpathMain->query($query)->item(0);
$producttitle = $product->getElementsByTagName("title")->item(0)->nodeValue;

if($_GET["link"]=="Y"){
$query =
"//products/product[id='".$_GET["mainid"]."']/units/unit[type='".$_GET["type"]."']";
}
else{
$query =
"//products/product[id='".$_GET["mainid"]."']/units/unit[title='".$_GET["title"]."']";
}
$unit = $xpathMain->query($query)->item(0);
$title = $unit->getElementsByTagName("title")->item(0)->nodeValue;
$descr = $unit->getElementsByTagName("descr")->item(0)->nodeValue;
$img = $unit->getElementsByTagName("img")->item(0)->nodeValue;
$typecount = $product->getElementsByTagName("types")->item(0)->getElementsByTagName("type")-
>length;
if ($contentwidth==""){
$contentwidth = "650";
}
$loopcount = 4;
if ($typecount>4){
$typewidth = ($contentwidth/4)."px";
$typeholderheight = "300px";
$typeheight = "150px";

}
else{
$typewidth = ($contentwidth/$typecount)."px";
$typeholderheight = "150px";
$typeheight = "150px";
}
if ($_GET["id"]=="GS" || $_GET["mainid"]=="GS"){
$typewidth = ($contentwidth/3)."px";
$typeholderheight = "160px";
$typeheight = "80px";
$loopcount = 3;
}
if ($_GET["id"]=="AH" || $_GET["mainid"]=="AH"){
$typewidth = ($contentwidth/3)."px";
$typeholderheight = "300px";
$typeheight = "150px";
$loopcount = 3;
}
if ($_GET["id"]=="HUM" || $_GET["mainid"]=="HUM"){
$typewidth = ($contentwidth/2)."px";
$typeholderheight = "300px";
$typeheight = "150px";
$loopcount = 2;
}
if ($_GET["id"]=="TMS" || $_GET["mainid"]=="TMS"){
$typewidth = ($contentwidth/2)."px";
$typeholderheight = "440px";
$typeheight = "220px";
$loopcount = 2;
}
if ($_GET["id"]=="FUR" || $_GET["mainid"]=="FUR"){
$typewidth = ($contentwidth/4)."px";
$typeholderheight = "340px";
$typeheight = "170px";
$loopcount = 4;
}
}
?>
Here is part of the products.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<products>
<product>
<id>AC</id>
<title>Air Conditioners</title>
<descr>
<![CDATA[ <p>Beyond cool. Reuben Trane patented his first air conditioning
system in 1931. And to this day, every Central Air Conditioning unit
and air conditioner Trane makes features the durability and reliability
that are the hallmarks of Trane products.</p> <p>Today's air conditioners
are more comfortable and efficient then ever. Whatever size your home,
whenever you need cool, comfortable, cleaner air, we're dedicated to
providing the very best investment you can make in ensuring the comfort
of you and your family.</p> ]]>
</descr>
<img>/wp-content/themes/indoorcomfortteam/images/products/ac-home.jpg</img>
<logoimg>/wp-content/themes/indoorcomfortteam/images/products/ac-logos.jpg</logoimg>
<units>
<unit>
<type>ueu</type>
<title>XL20i</title>
<descr>
<![CDATA[ <p><b>Efficient performance </b><br /> The XL20i's SEER
(Seasonal Energy Efficiency Ratio) rating of up to 20.00 is among
the highest energy efficiency rating of any air conditioner available
today. The XL20i has two compressors: one for milder weather and
a second larger compressor for those extremely hot days. It's like
having two units in one.</p> <p><b>ComfortLink II Capable</b> (available
on select models) <br /> ComfortLink II communicating technology
(available on select models) connects all of your key components
so your system automatically charges, configures and calibrates
for optimal performance through the lifetime of your products. When
the optional Telephone Access Module (TAM) is added, you can conveniently
adjust settings and receive system updates wherever you are.</p>
<p><b>Economical operation </b><br /> Increased efficiency may substantially
lower your home cooling costs.</p> <p><b>Quiet comfort </b><br />
Variable-speed fan motor adjusts speed to quietly provide maximum
comfort.</p> <p><b>Durable construction </b><br /> Materials for
all components are tested again and again for long-lasting performance
and durability.</p> <p><b>Better indoor air </b><br /> Add a Trane
Air Cleaner to your system for filtering that removes more dust,
pollen and other irritants throughout your entire home for a cleaner,
healthier, more comfortable home. And Trane CleanEffects&trade;
is now proven to remove more than 99% of the common flu virus from
your home's filtered air.</p> ]]>
</descr>
<img>/wp-content/themes/indoorcomfortteam/images/products/ac.jpg</img>
</unit>
<unit>
<type>ueu</type>
<title>XL16i</title>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top