Jump to content

Why am I getting a parser error?


the_el_duderino

Recommended Posts

Sorry if this is a terrible question, I'm a .NET programmer and having a helluva time picking up PHP for a new client.  I keep getting a parser error for line 163 which is where the try statement starts.  Can anyone tell what's going on?

 

$doc = new DOMDocument();
            $doc->load( 'cats.xml' );
            $cats = $doc->getElementsByTagName("category");
            $category = '';
            foreach($cats as $cater) {
                try {
                    $catids = $cater->getElementsByTagName("category_id");
                    $catid = $catids->item(0)->nodeValue;
                    $catnames = $cater->getElementsByTagName("category_name");
                    if($_GET['cat3'] > 0) {
                        if($_GET['cat3'] == $catid) {
                            $category = $catnames->item(0)->nodeValue;
                        }
                    } elseif ($_GET['cat2'] > 0) {
                        if($_GET['cat2'] == $catid) {
                            $category = $catnames->item(0)->nodeValue;
                        }
                    } elseif($_GET['cat1'] == $catid) {
                        $category = $catnames->item(0)->nodeValue;
                    }
                } catch (Exception $e) {
                }
            }

Link to comment
https://forums.phpfreaks.com/topic/130645-why-am-i-getting-a-parser-error/
Share on other sites

Just ran php info and yep, it's php 4.3.2 ... I don't have the ability to upgrade their server software though.  I tried removing the try statement and still get a parser error.  THis time it's:

 

Parse error: parse error in /home/cust2/user1226371/html/testdirectory/results.php on line 164

 

Which is the line: $catid = $catids->item(0)->nodeValue;

yea man, I mean, whenever I take on a new client I usually put them on one of my dedicated servers, but this client had an old site and they don't want to switch.  They are paying the big bucks though, so I'm dealing with it.

 

So, that worked, but I'm getting this error now about the first two lines of my code.  Is DOMDocument supported in php 4?

 

Warning: domdocument() expects at least 1 parameter, 0 given in /home/cust2/user1226371/html/testdirectory/results.php on line 158

 

Fatal error: Call to undefined function: load() in /home/cust2/user1226371/html/testdirectory/results.php on line 159

Except for a very few minor areas, php4 code will work under php5, given the same php.ini settings - http://us3.php.net/manual/en/migration5.incompatible.php

 

If you have an available server/development system with php5 that you could configure with the equivalent php.ini settings and test and show that their existing site works under php5, perhaps you can get even more work from them to perform the upgrade.

 

If they then upgrade, whatever you are attempting will work as is.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.