the_el_duderino Posted October 29, 2008 Share Posted October 29, 2008 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 More sharing options...
DarkWater Posted October 29, 2008 Share Posted October 29, 2008 1) What's the actual error? 2) Are you running PHP4? PHP4 does not support try/catch blocks, and you should really upgrade. Link to comment https://forums.phpfreaks.com/topic/130645-why-am-i-getting-a-parser-error/#findComment-677920 Share on other sites More sharing options...
the_el_duderino Posted October 29, 2008 Author Share Posted October 29, 2008 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; Link to comment https://forums.phpfreaks.com/topic/130645-why-am-i-getting-a-parser-error/#findComment-677934 Share on other sites More sharing options...
DarkWater Posted October 29, 2008 Share Posted October 29, 2008 $catid = $catids->item[0]->nodevalue; And why can't you upgrade it? Is it a shared host? Link to comment https://forums.phpfreaks.com/topic/130645-why-am-i-getting-a-parser-error/#findComment-677941 Share on other sites More sharing options...
the_el_duderino Posted October 29, 2008 Author Share Posted October 29, 2008 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 Link to comment https://forums.phpfreaks.com/topic/130645-why-am-i-getting-a-parser-error/#findComment-677950 Share on other sites More sharing options...
DarkWater Posted October 29, 2008 Share Posted October 29, 2008 Apparently it's only available in PHP5 (as far as the manual says...). Try out SimpleXML if you want. >_< Link to comment https://forums.phpfreaks.com/topic/130645-why-am-i-getting-a-parser-error/#findComment-677953 Share on other sites More sharing options...
PFMaBiSmAd Posted October 29, 2008 Share Posted October 29, 2008 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. Link to comment https://forums.phpfreaks.com/topic/130645-why-am-i-getting-a-parser-error/#findComment-677968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.