rdrews Posted September 28, 2010 Share Posted September 28, 2010 I have some code that works fine on my dev server but does not work on my production server. Dev server has PHP version 5.2.5 and production server has PHP version 5.1.6. This is the part of the code that isn't working on the prod. server: $xmlDoc=new DOMDocument(); $xmlDoc->loadXML($tmpDoc); $x=$xmlDoc->getElementsByTagName('link'); //get the q parameter from URL $q=$_GET["q"]; //lookup all links from the xml file if length of q>0 if (strlen($q)>0) { $hint=""; for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { //find a link matching the search text if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<tr><td><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</td></tr>"; } else { $hint=$hint . "<tr><td><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a></td></tr>"; } } } } } $tmpDoc is a variable that holds database information in xml form. It basically looks like this: $tmpDoc = $tmpDoc . "<link><title>" . $row['CustomerName'] . "****" . $row['Rep'] . "****" . $row['InstallDate'] . "****" . $row['PaidDate'] . "</title><url>accountPage.php?AccNum=" . $row['AccountNum'] . "</url></link>"; ...that is inside a while loop that loops through the rows returned by a query. Basically, as I said, the whole thing works fine on my dev server but on the production server it never makes it into the for loop so I guess the condition $i<($x->length) isn't being met. I'm at a bit of a loss here. Is there anything like the PHP version or Apache version that may cause the "->" operator to not work? The prod PHP version isn't that much older than my dev PHP version so I doubt that's the issue but it's about all I can think of. Thanks! Link to comment https://forums.phpfreaks.com/topic/214654-help-with-code-that-works-on-one-server-but-not-another/ Share on other sites More sharing options...
AbraCadaver Posted September 28, 2010 Share Posted September 28, 2010 error_reporting(E_ALL); ini_set('display_errors', '1'); Most likely $xmlDoc and/or $x are not objects. Link to comment https://forums.phpfreaks.com/topic/214654-help-with-code-that-works-on-one-server-but-not-another/#findComment-1116893 Share on other sites More sharing options...
rdrews Posted September 28, 2010 Author Share Posted September 28, 2010 error_reporting(E_ALL); ini_set('display_errors', '1'); Most likely $xmlDoc and/or $x are not objects. I get: Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: xmlParseEntityRef: no name in Entity, line: 1 in /path/to/page.php on line 106 Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: xmlParseEntityRef: no name in Entity, line: 1 in /path/to/page.php on line 106 Line 106 is: $xmlDoc->loadXML($tmpDoc); Link to comment https://forums.phpfreaks.com/topic/214654-help-with-code-that-works-on-one-server-but-not-another/#findComment-1116896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.