Re: problem with pcode function

From: Date: Wed, 18 Jul 2007 07:39:14 +0000
Subject: Re: problem with pcode function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-259090@lists.php.net to get a copy of this message
Ross wrote:
I have this postcode selector working on my localhost but remotely it gives a parse error. It should only call the function when the postcode is submitted. Any ideas? The error is: Parse error: parse error, unexpected T_NEW in /homepages/3/d154908384/htdocs/legalsuk/consultants/nearest.php on line 26 <?php function pcaStoredNearest($origin, $units, $distance, $items, $account_code, $license_code, $machine_id) {
     //Build the url
      $url = "http://services.postcodeanywhere.co.uk/xml.aspx?";
      $url .= "&action=stored_nearest";
      $url .= "&origin=" . urlencode($origin);
      $url .= "&units=" . urlencode($units);
      $url .= "&distance=" . urlencode($distance);
      $url .= "&items=" . urlencode($items);
      $url .= "&account_code=" . urlencode($account_code);
      $url .= "&license_code=" . urlencode($license_code);
      $url .= "&machine_id=" . urlencode($machine_id);
      //Make the request
      $data = simplexml_load_string(file_get_contents($url));
      //Check for an error
      if ($data->Schema['Items']==2)
         {
             throw new exception ($data->Data->Item['message']);
         }
      //Create the response
      foreach ($data->Data->children() as $row)
         {
              $rowItems="";
              foreach($row->attributes() as $key => $value)
                  {
                      $rowItems[$key]=strval($value);
                  }
            $output[] = $rowItems;
         }
      //Return the result
      return $output;
} } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title></title> <?php include ('../pageElements/doc_head.php'); ?> <style type="text/css"> table { width:400px; } th { text-align:right; text-decoration:none; font-weight:normal; } td{ width:400px; } </style> <link href="../css/lss.css" rel="stylesheet" type="text/css" /> </head> <body id="services"> <div id="container"> <?php include ('../pageElements/header.php'); ?> <div id="content-top"> </div> <div id="content-middle"> </div> Find Your Nearest Consultant by Entering Your Postcode Below<br /><br /> <form action="" method="post"> <input name="pcode" type="text" style="width:100px;"> <input name="" type="submit" style="width:50px;"> </form> </div> <div id="result"> <?php if (isset($_POST['pcode'])){ $result = pcaStoredNearest($pcode, 'MILES', 'STRAIGHT', '2', 'xxxxx', 'xxxxx', ''); echo $result[0]['description']; } ?> </div> </div>
Is your server running PHP5, the same as your localhost? Darren

« previous php.general (#259090) next »