INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Error on PHP file, not sure what to do

Error on PHP file, not sure what to do

(OP)
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>

RE: Error on PHP file, not sure what to do

Is there a plugin used for this "product section"?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close