Page 1 of 1

Help with PHP include file not woring on my server.

Posted: Sat Jun 24, 2006 10:25 pm
by hisakata
Hello all, this is my first post. I have a dedicated server with php installed. This is a windows environment and I know it has something to do with it. I am tyring to call an include file and it will not work.

It works here
http://matsukidesignsolutions.com/pharm ... ght%20loss

This server is linux

It doesn't work here
http://www.bestpharmadeals.com/results. ... ght%20loss

THis is windows environment

Can someon please help me with any ideas why it wouldn't be working? I am running PHP 4 on this windows environment. I appreciate any help. Thank you so much!

Posted: Sat Jun 24, 2006 10:37 pm
by feyd
care to... post your code?

Code

Posted: Sat Jun 24, 2006 10:58 pm
by hisakata
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


This is the index results page

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title><?echo $keyword?> from Pharma Deals - The Latest Pharmaceuticals at the lowest prices!</title>
	<link rel="stylesheet" type="text/css" href="pharmacss.css">
	

</head>

<body>
<table width="769" cellpadding="0" cellspacing="0" border="0" align="center">
  <tr style="background: url(images/topbarbackground.gif);">
    <td width="178"><a href="index.php"><img src="images/bestpharmalogo.gif" width="178" height="129" border="0" alt="The Latest Pharmaceuticals at the lowest prices!"></a></td>
	<td align="right"><img src="images/interiortop.jpg" width="360" height="129" border="0" alt="The Latest Pharmaceuticals at the lowest prices!"></td>
  </tr>
</table>

<table width="769" cellpadding="0" cellspacing="0" border="0" align="center">
  <tr valign="top">
    <td width="177" style="padding-right:11px;">
	  <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
          <td><?php require_once('includes/leftnav.inc'); ?>
</td>
	    </tr>
	  </table>
	  <table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:9px; height:117px">
		<tr>
		   <td width="177" style="background-color:#cccccc;"><?php require_once('includes/lefthighlight.inc'); ?></td>
		</tr>
	  </table>
<?php require_once('includes/topsellers.inc'); ?>
	</td>
	<td>
	  <table width="100%" cellpadding="0" cellspacing="0" border="0" style="height:72px">
		<form action="results.php">
		<tr style="background-color:#5e9ed4;">
	      <td width="120" align="right"><img src="images/searchonblue.gif" width="96" height="15" border="0" alt=""></td><td width="200" align="right"><input type="text" style="width:190px; border: 1px solid #7f9db9; font-family:arial; font-size:13px;" name="keyword" value=""></td><td width="80" align="right"><input type="submit" style="width:70px; font-family:arial; font-size:13px;" value="Search"></td><td align="right"><img src="images/interior.jpg" width="151" height="72" border="0" alt="The Latest Pharmaceuticals at the lowest prices!"></td>
		</tr>
		</form>
	  </table>
	  
	  
<?include 'feed.php'?>
	
	  
	</td>
  </tr>
</table>

<table width="769" cellpadding="0" cellspacing="0" border="0" align="center">
  <tr>
    <td style="padding-top:9px; padding-bottom:9px;"><img src="images/blankgif.gif" style="background-color:#999999;" width="769" height="3" border="0" alt=""></td>
  </tr>
</table>
<table width="769" cellpadding="0" cellspacing="0" border="0" align="center">
  <tr>
    <td style="background-color:#cccccc; height:42px;"><img src="images/blankgif.gif" width="1" height="42" border="0" alt=""></td>
  </tr>
  <tr>
    <td align="right"><p>© 2006 BestPharmaDeals. All Rights Reserved.</p></td>
  </tr>
</table>

</body>
</html>


This is what that page should pull in
<?
function display_url($url)
{
	$url = str_replace("http://", "", $url);
	if (strpos($url, "/", 5))
	{
		$position_slash = strpos($url, "/", 5);
	}
	else
	{
		$position_slash = strlen($url);
	}
	$url = substr($url, 0, $position_slash);
	return $url;
}
?>

<?php
// findwhat_rs.php
// This PHP template accepts a search term, calls the FindWhat XML feed, and parses it out into an array.
// This template now combines both the PHP XML extensions and a brute force parser
// The PHP extensions used are from 'expat'
// Information can be found here: http://us3.php.net/manual/en/ref.xml.php
// Lon Lentz: lon.lentz@findwhat.com
// For FindWhat
// Copyright FindWhat.Com, 2004
// Last update: 21-July-2004 -- Added xml parsing object
//

// set affiliate id number here
$affid = '52257';

// set authorization token number here
$at = "9M9KGKIMI";

// set the number of results to return
$dc = 6;

// pull the search term
$mt = urlencode(urldecode($keyword));

// set adult filter: 0 - off, 1 - on, when on will not return adult oriented results
// $fl = '0';
// this is a test section for changing the adult flag on the fly
$fl = '0';

// set the starting base, list selections start at n+1 for base=n
if (!$base) $base = '0';

// get users IP number
$ipnum = $_SERVER['REMOTE_ADDR'];

// The submission doc for requesting the search results
$doc = "/bin/findwhat.dll?getresults&base=$base&dc=$dc&mt=$mt&ip_addr=$ipnum&aff_id=$affid&fl=$fl&fmt=xml8859&at=$at";

// FindWhat's search URL
$url = 'v10.xmlsearch.miva.com';

// Make search request
$fp = fsockopen ($url, 80, $errno, $errstr, 30);
if (!$fp) {
	echo "$errstr ($errno)<br/>\n";
} else {
	fputs ($fp, "GET $doc HTTP/1.0\r\nHost: " . $url . "\r\n\r\n");
	while (!feof($fp)) {
		$fwxml = $fwxml . fgets ($fp,1024);
	}
	fclose ($fp);
}

$use_xml_parser = 1;
// attempt to use xml parser

$xml_test = xml_parser_create() or die ($use_xml_parser = 0);

if ($use_xml_parser == 1) {

	// remove the http headers
	$headstart = strpos($fwxml,'<?xml');
	$fwxml = trim(substr($fwxml,$headstart));

	$xml_out = xml2array($fwxml);

	$related_array = array();
	for ($i = 0; $i < count($xml_out["relatedsearches"][0]["relation"]); $i++) {
		$related_array[$i] = array();
		$related_array[$i][0] = $xml_out["relatedsearches"][0]["relation"][$i]["keyword"];
		$related_array[$i][1] = $xml_out["relatedsearches"][0]["relation"][$i]["passback_param"];
		$related_array[$i][2] = urlencode($xml_out["relatedsearched"][0]["relation"][$i]["keyword"]);
	}

	$counter = $base + 1; // keep track of rank position
	$outputarray = array();
	for ($h = 0; $h < count($xml_out["adresults"][0]["record"]); $h++) {
		$outputarray[$h] = array();
		$outputarray[$h][0] = $xml_out["adresults"][0]["record"][$h]["title"];
		$outputarray[$h][1] = $xml_out["adresults"][0]["record"][$h]["url"];
		$outputarray[$h][2] = $xml_out["adresults"][0]["record"][$h]["description"];
		$outputarray[$h][3] = $xml_out["adresults"][0]["record"][$h]["bidprice"];
		$outputarray[$h][4] = $xml_out["adresults"][0]["record"][$h]["clickurl"];
		$outputarray[$h][5] = $xml_out["adresults"][0]["record"][$h]["impressionurl"];
		$outputarray[$h][6] = $counter;
		$counter++;
	}

} else { // no XML capability found, brute force the parsing

	// 7/15/04
	// get related searches
	$numofmatch = preg_match_all('{<keyword>(.+)</passback_param>}', $fwxml, $related, PREG_SET_ORDER);

	// extract the keyword and pass back parameter
	$related_array = array();
	for ($j=0;$j<count($related)-1;$j++) {
		$related_array[$j] = explode('</keyword><passback_param>',$related[$j][1]);
		$related_array[$j][2] = urlencode($related_array[$j][0]);
	}

	// remove the http and xml headers and the related search
	$headstart = strpos($fwxml,'<record>');
	$fwxml = trim(substr($fwxml,$headstart));

	// break <record>s apart into array
	$fwarray = explode('</record>',$fwxml);

	// break each <record> up into component pieces and place into 2d array
	$counter = $base + 1; // keep track of rank position
	$outputarray = array(); // array for placing output
	for ($i=0;$i<count($fwarray)-1;$i++) {
		$keeper = str_replace(']]>','',$fwarray[$i]);

		$keeper = str_replace('</url>','~',$keeper);
		$keeper = str_replace('<![CDATA[','',$keeper);
		$keeper = str_replace('</description>','~',$keeper);
		$keeper = str_replace('</bidprice>','~',$keeper);
		$keeper = str_replace('</title>','~',$keeper);
		$keeper = str_replace('</clickurl>','~',$keeper);
		$keeper = str_replace('</impressionurl>','~',$keeper);
		$keeper = trim(strip_tags($keeper));

		$outputarray[$i] = explode('~',$keeper);
		$outputarray[$i][6] = $counter;
		$counter++;
	}

} // end of if xml_parser

// This function can be used for trimming descriptions to a set length
function fw_trunc_desc ($description) {
	$Truncate_To_This_Length = 100;
	$description = substr($description,0,$Truncate_To_This_Length);
	$lastspace = strrpos($description,chr(32));
	if ($lastspace == 0) {
		$description = $description . '...';
	} else {
		$description = substr($description,0,$lastspace) . '...';
	}
	return $description;
}


function xml2array($data)
  {
   //mvo voncken@mailandnews.com
   //original ripped from  on the php-manual:gdemartini@bol.com.br
   //to be used for data retrieval(result-structure is Data oriented)
   $p = xml_parser_create();
   xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1);
   xml_parse_into_struct($p, $data, &$vals, &$index);
   xml_parser_free($p);

   $tree = array();
   $i = 0;
   //array_push($tree, array('tag' => $vals[$i]['tag'], 'attributes'=> $vals[$i]['attributes'],                            'children' => ));
   $tree = GetChildren($vals, $i);
   return $tree;
  }

 function GetChildren($vals, &$i)
  {
   $children = array();
   if ($vals[$i]['value']) array_push($children, $vals[$i]['value']);

   $prevtag = "";
   while (++$i < count($vals)) // so pra nao botar while true 
   {
     switch ($vals[$i]['type'])
     {
         case 'cdata':
           array_push($children, $vals[$i]['value']);
           break;
         case 'complete':
           $children[ strtolower($vals[$i]['tag']) ] = $vals[$i]['value'];
           break;

         case 'open':

           //restartindex on unique tag-name
           $j++;
           if ($prevtag <> $vals[$i]['tag']) {
                   $j = 0;
                   $prevtag = $vals[$i]['tag'];
           }
           $children[ strtolower($vals[$i]['tag']) ][$j] = GetChildren($vals,$i);
           break;

         case 'close':
           return $children;
     }
   }
  }



// $outputarray is now a 2 dimensional array containing FindWhat search results, the second dimension breaks down like this, by index:
//
//  [$i][0] - title
//  [$i][1] - url
//  [$i][2] - description
//  [$i][3] - bidprice
//  [$i][4] - click url    This is the url that needs to be set up as the click through link
//  [$i][5] - impression url
//  [$i][6] - rank position
//
//
// $related_array is now a 2 dimensional array containing the related search keywords and the pass back parameter
//
//  [$j][0] - keyword for display
//  [$j][1] - pass back parameter
//  [$j][2] - url safe keyword
//
// This is a demo layout similar to FindWhat's html return
// everything below the php closing tag can be deleted without affecting this template

?>

<script>
	function NextPage(page)
	{
		document.frmResults.elements["base"].value = parseInt(document.frmResults.elements["base"].value) + 10;
		document.frmResults.action= "findwhat_rs.php";
		document.frmResults.submit();
	}
	function PrevPage(page)
	{
		document.frmResults.elements["base"].value = parseInt(document.frmResults.elements["base"].value) - 10;
		document.frmResults.action="findwhat_rs.php";
		document.frmResults.submit();
	}
</script>

<!-----------THIS SECTION WRITES OUT THE RESULTS------------>
  <table width="100%" cellpadding="5" cellspacing="0" border="0" style="margin-top:4px;">
<?
	$j=1;
for ($i=0; $i<count($outputarray); $i++)

{
?>
<? $outputarray[$i][1] = display_url($outputarray[$i][1]); ?>

		<tr valign="top">
	      <td width="50%" align="center" style="background-image: url(images/mp2.gif); background-repeat:no-repeat; background-position: 50% 100%;"><p><a href="<?echo $outputarray[$i][4]?>"><img src="images/recommend0<?echo $j;?>.jpg" width="212" height="88" border="0" alt=""></a><br><a href="<?echo $outputarray[$i][4]?>" class="title2"><?echo $outputarray[$i][0]?></a> 
     <br>
     <a href="<?echo $outputarray[$i][4]?>" class="description2"><?echo $outputarray[$i][2]?></a><a href="" class="description2"></a>  
     <a href="<?echo $outputarray[$i][4]?>" class="url2">Read&nbsp;More&nbsp;>></a></p></td>
	 <?$i++; $j++;?>
		  <td align="center" style="background-image: url(images/mp2.gif); background-repeat:no-repeat; background-position: 50% 100%;"><p><a href="<?echo $outputarray[$i][4]?>"><img src="images/recommend0<?echo $j;?>.jpg" width="212" height="88" border="0" alt=""></a><br>
		    <a href="<?echo $outputarray[$i][4]?>" class="title2"><?echo $outputarray[$i][0]?></a><a href="" class="title2"></a> 
     <br><a href="<?echo $outputarray[$i][4]?>" class="description2"><?echo $outputarray[$i][2]?></a>  
     <a href="<?echo $outputarray[$i][4]?>" class="url2">Read&nbsp;More&nbsp;>></a></p></td>
		</tr>
		<?$j++;?>
	 
<p>
<?	
}

?>
 </table>


<!---------------END OF SECTION----------------------->




Thank you!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]