Jump to content

Help with code that works on one server but not another


rdrews

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.