Warning: SoapClient::SoapClient() [function.SoapClient-SoapClient]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\uploadaddress\upload1.php on line 64

Warning: SoapClient::SoapClient(http://geocoder.us/dist/eg/clients/GeoCoderPHP.wsdl) [function.SoapClient-SoapClient]: failed to open stream: No such file or directory in C:\xampp\htdocs\uploadaddress\upload1.php on line 64

Warning: SoapClient::SoapClient() [function.SoapClient-SoapClient]: I/O warning : failed to load external entity "http://geocoder.us/dist/eg/clients/GeoCoderPHP.wsdl" in C:\xampp\htdocs\uploadaddress\upload1.php on line 64

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://geocoder.us/dist/eg/clients/GeoCoderPHP.wsdl' in C:\xampp\htdocs\uploadaddress\upload1.php:64 Stack trace: #0 C:\xampp\htdocs\uploadaddress\upload1.php(64): SoapClient->SoapClient('http://geocoder...') #1 {main} thrown in C:\xampp\htdocs\uploadaddress\upload1.php on line 64

    Can you post the script? Most notably the line that contains the error specified and the few lines before/after it.

      Actually, it might be better to post the entire client code.

      The error basically says that your client cannot access the WSDL file. You may like to navigate to the URL then copy and paste the text into a local file for testing purposes.

        hi Valdhor
        please see my code

        <?php
        
        if(isset($_GET['module']) && !empty($_GET['module'])) 
        {
        		$module = $_GET['module']; 
        		$table='habitat_coupon_subscribers41';	
        
        	$target_path = '';
        	$csvfilename=$_FILES['userfile']['name'];
        
        	$fp = fopen($_FILES['userfile']['tmp_name'], 'r') or die('Could not open file!');
        
        	$target_path = "temp/". basename( $_FILES['userfile']['name']); 
        	$ext = substr(strrchr($target_path, '.\.'), 1);
        
        	$userid = $_COOKIE["TestCookie"];
        
        
        			if($ext == "csv")
        			{
        
        
        				//$x=0;
        				$file_content = file($_FILES['userfile']['tmp_name']); 
        
        
        				for($i=1; $i<count($file_content); $i++)
        				{ 
        				$varia= explode(",", $file_content[$i]);
        				//print_r($varia); 
        				if(sizeof($varia) > 1)
        				{
        
        					foreach($varia as $k=>$v)
        					{
        						$v = trim($v,"\x7f..\xff\x0..\x1f");
        					}
        	        // insert new record into database
        			if( ($varia[0]=="") && ($varia[1]=="") && ($varia[2]=="") && ($varia[3]=="") && ($varia[4]=="") && ($varia[5]=="") && ($varia[6]=="") && ($varia[8]=="") && ($varia[7]=="") )
        			{
        
        			}
        			else{ 
        						$conn=mysql_connect("localhost","root","root");
        			$db=mysql_select_db("testdatabase");
        
        			$insert = "INSERT INTO $table ( Address,City,State,Zip) 
        		VALUES('".trim($varia[0],"\x7f..\xff\x0..\x1f")."','".trim($varia[1],"\x7f..\xff\x0..\x1f")."','".trim($varia[2],"\x7f..\xff\x0..\x1f")."','".trim($varia[3],"\x7f..\xff\x0..\x1f")."')"; 
        //echo $insert; die;
        			$res=mysql_query($insert);
        
        		}
        		}
        		}
        	$table1=date("Y_m_dhs");	
        	$table2="uploaddata".$table1;
        	$databasetbl= "CREATE TABLE $table2 (
        id INT( 4 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
        Address VARCHAR( 50 ) NOT NULL ,
        City VARCHAR( 50 ) NOT NULL ,
        State VARCHAR( 50 ) NOT NULL ,
        Zip VARCHAR( 50 ) NOT NULL ,
        langitude VARCHAR( 30 ) NOT NULL ,
        lat VARCHAR( 30 ) NOT NULL 
        );";
        //echo $databasetbl;
        		//	die;
        		//echo $table2; die;
        	$result_database=mysql_query($databasetbl);
        
        $databasetbl_sub= "CREATE TABLE habitat_coupon_subscribers4 (
        id INT( 4 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
        Address VARCHAR( 50 ) NOT NULL ,
        City VARCHAR( 50 ) NOT NULL ,
        State VARCHAR( 50 ) NOT NULL ,
        Zip VARCHAR( 50 ) NOT NULL ,
        langitude VARCHAR( 30 ) NOT NULL ,
        lat VARCHAR( 30 ) NOT NULL 
        );";
        //echo $databasetbl;
        		//	die;
        		//echo $table2; die;
        	$result_database=mysql_query($databasetbl_sub);	
        		$query="select id,Address,city,state,zip from ".$table;
        					//echo $query; die;
        					$res_1=mysql_query($query);
        
        
        		while($row=mysql_fetch_array($res_1))
        				{
        					$address = $row['1']. ' '. $row['2']. ' ' . $row['3']. ' '. $row['4'];
        
        					$address_with_id = $row['0'].' '.$row['1']. ' '. $row['2']. ' ' . $row['3']. ' '. $row['4'];
        					//echo $address; 
        					echo "<br>";
        		//	 printf("Get geocode for address: %s\n",$address);
        
        			 $wsdl = 'http://geocoder.us/dist/eg/clients/GeoCoderPHP.wsdl';
        			      $client = new SoapClient($wsdl);
        
        				   $result = $client->geocode($address);
        
        
        $lat= $result[0]->lat;
        	$long= $result[0]->long;
        	$table3=$table2;
        //	echo $table3; die;
        	$table1='habitat_coupon_subscribers4';
        
        
         $insert2 = "INSERT INTO $table2 ( Address,City,State,Zip,Langitude,lat) 
         			VALUES('".trim($row['1'])."','".trim($row['2'])."','".trim($row['3'])."','".trim($row['4'])."','".$long."','".$lat."')"; 
        //echo $insert2; die;
        	$res=mysql_query($insert2);
        
        $insert3 = "INSERT INTO $table1 ( Address,City,State,Zip,Langitude,lat) 
        		VALUES('".trim($row['1'])."','".trim($row['2'])."','".trim($row['3'])."','".trim($row['4'])."','".$long."','".$lat."')"; 
        //echo $insert2; die;
        	$res=mysql_query($insert3);
        
        					}//close while loop			
        	}	
        }
        if($res == 1)
        {
        	echo "new table name is ".$table2;
        	echo "<br>"."<a href='upload1_result.php'>Click here to view the database tables</a>";
        }
        
        
        
        ?>
        <STYLE type=text/css>PRE {
        	PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-BOTTOM: 15px; MARGIN-LEFT: 40px; OVERFLOW: auto; WIDTH: 370px; COLOR: #222264; PADDING-TOP: 15px
        }
        #rc_notify {
        	PADDING-RIGHT: 3px; DISPLAY: none; PADDING-LEFT: 3px; RIGHT: 0px; VISIBILITY: hidden; PADDING-BOTTOM: 3px; MARGIN: 5px; COLOR: white; PADDING-TOP: 3px; POSITION: absolute; TOP: 0px; BACKGROUND-COLOR: red
        }
        UNKNOWN {
        	POSITION: fixed
        }
        </STYLE>
        
        <SCRIPT language=javascript>
        function getScrollTop() {
        if ( document.documentElement.scrollTop )
           return document.documentElement.scrollTop;
        return document.body.scrollTop;
        }
        
        function showNotify( str ) {
           var elem = document.getElementById('rc_notify');
           elem.style.display = 'block';
           elem.style.visibility = 'visible';
        
           if ( elem.currentStyle && elem.currentStyle.position == 'absolute' ) {
              elem.style.top = getScrollTop();
           }
        
           elem.innerHTML = str;
        }
        
        function hideNotify() {
           var elem = document.getElementById('rc_notify');
           elem.style.display = 'none';
           elem.style.visibility = 'hidden';
        }
        
        window.onscroll = function () {
           var elem = document.getElementById('rc_notify');
           if ( !elem.currentStyle || elem.currentStyle.position != 'absolute' ) {
              window.onscroll = null;
           } else {
              window.onscroll = function () { elem.style.top = getScrollTop(); };
              document.getElementById('rc_notify').style.top = getScrollTop();
           }
        }
        </SCRIPT>
        <script type="text/javascript" src="uploader.js" ></script>
        <form enctype="multipart/form-data" name="Import" method="POST" action="upload1.php?module=upload" onsubmit="showNotify('<strong>Loading...</strong>')">
        <input type="hidden" name="plugin" value="contacts" />
        <input type="hidden" name="importType" value="VCard" />
        <input type="hidden" name="visibility" value="private" />
        <input type="hidden" name="action" value="importContacts" />
        <input type="hidden" name="parentId" value="0" />
        <input type="hidden" name="MAX_FILE_SIZE" value="1000000">
        <span><div id="rc_notify"></div></span>
        <table width="100%"  border="0" cellspacing="1" cellpadding="2">
          <tr class="mangtableyellow" >
            <td colspan="4" align="left" nowrap bgcolor="#FFFFFF"><font color="#FF0000">
        	<?php if(!empty($_SESSION['errMessage'])) echo $_SESSION['errMessage']; $_SESSION['errMessage'] = '';?></font></td>
          </tr>
          <td>
        <table width="100%" border="0" cellspacing="1" cellpadding="6" class="tabForm">
        
        <tr class="mangtableyellow">
        <th align="left" class="dataLabel" colspan="4">SELECT FILE TO IMPORT</th>
        </tr>
        <tr>
        <td class="mangtablewhite">
        <input type="hidden" />
        <input size="60" name="userfile" type="file"/>
        </td>
        </tr>
        <tr class="mangtablewhite"> 
        <td align="left"><p>
          <input title="IMPORT" accessKey="" class="button" type="submit" name="button" value="Import"  onclick="return verify_data(this.form);">
        </p>
          <p>&nbsp; </p></td>
        
        </tr>
        </table> </td></table>
        </form>

          For what you are doing, you don't even need a WSDL.

          $client = new SoapClient(null, array(
          						"uri" => "http://rpc.geocoder.us/Geo/Coder/US/", 
          						"location" => "http://geocoder.us/service/soap"
          						));
          
          $address = "1600 Pennsylvania Av, Washington, DC";
          try
          {
          	$GeocoderResult = $client->geocode($address);
          	print("<pre>");
          	print("Latitude: " . $GeocoderResult[0]->lat . "<br />");
          	print("Longitude: " . $GeocoderResult[0]->long);
          }
          catch (SoapFault $exception)
          {
          	print("<pre>");
          	print($exception);
          	print("<pre>");
          }

            Hi Valdhor
            Thanks for reply.
            I need to upload the csv file from the application and generate the langitude and latitude to be generated please see my example csv file how can i write upload script and include the following code sent by you. please help me

            with upload script also

            i have included in zip in excel file along with this post please help me with upload code and along with the following code included in the application

              The following code will take your csv file, get latitude and logitude and write it to a results file...

              $client = new SoapClient(null, array(
                                      "uri" => "http://rpc.geocoder.us/Geo/Coder/US/",
                                      "location" => "http://geocoder.us/service/soap"
                                      ));
              
              $firstLineSkipped = false;
              $inFileHandle = @fopen("examplesheet.csv", "r");
              if($outFileHandle = @fopen("results.csv", "w"))
              {
              	fclose($outFileHandle);
              }
              $outFileHandle = @fopen("results.csv", "a");
              if ($inFileHandle && $outFileHandle)
              {
                  while (!feof($inFileHandle))
                  {
                      $line = fgets($inFileHandle, 4096);
                      if($firstLineSkipped)
                      {
              	        $addressArray = explode(",", $line);
              			$address = trim($addressArray[0], " \"\n\r");
              			$city = trim($addressArray[1], " \"\n\r");
              			$state = trim($addressArray[2], " \"\n\r");
              			$zip = trim($addressArray[3], " \"\n\r");
              
              		$fullAddress = $address . "," . $city . "," . $state . " " . $zip;
              		print($fullAddress . "<br />");
              		try
              		{
              		    $GeocoderResult = $client->geocode($fullAddress);
              		    if(count($GeocoderResult) > 0)
              		    {
              				$latitude = $GeocoderResult[0]->lat;
              				$longitude = $GeocoderResult[0]->long;
              				$number = $GeocoderResult[0]->number;
              				$street = $GeocoderResult[0]->street;
              				$type = $GeocoderResult[0]->type;
              				$city = $GeocoderResult[0]->city;
              				$state = $GeocoderResult[0]->state;
              				$zip = $GeocoderResult[0]->zip;
              				$suffix = $GeocoderResult[0]->suffix;
              				$outputLine = $number . " " . $street . " " . $type . " " . $suffix . "," . $city . "," . $state . " " . $zip . "," . $latitude . "," . $longitude . "\n";
              				fwrite($outFileHandle, $outputLine);
              		    }
              		}
              		catch (SoapFault $exception)
              		{
              		    print("<pre>");
              		    print($exception);
              		    print("<pre><br />");
              		}
              		set_time_limit(30);
              		sleep(2);
                  }
                  $firstLineSkipped = true;
              }
              fclose($inFileHandle);
              fclose($outFileHandle);
              }
              
              

                hi Valdhor
                it worked thanks. I have changed in the following way
                geocoder2.php

                <!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>Untitled Document</title>
                </head>
                
                <body>
                <form enctype="multipart/form-data" name="Import" method="POST" action="geocoder1.php?module=upload" onsubmit="showNotify('<strong>Loading...</strong>')">
                <input type="hidden" name="plugin" value="contacts" />
                <input type="hidden" name="importType" value="VCard" />
                <input type="hidden" name="visibility" value="private" />
                <input type="hidden" name="action" value="importContacts" />
                <input type="hidden" name="parentId" value="0" />
                <input type="hidden" name="MAX_FILE_SIZE" value="1000000">
                <span><div id="rc_notify"></div></span>
                <table width="100%"  border="0" cellspacing="1" cellpadding="2">
                  <tr class="mangtableyellow" >
                    <td colspan="4" align="left" nowrap bgcolor="#FFFFFF"><font color="#FF0000">
                	<?php if(!empty($_SESSION['errMessage'])) echo $_SESSION['errMessage']; $_SESSION['errMessage'] = '';?></font></td>
                  </tr>
                  <td>
                <table width="100%" border="0" cellspacing="1" cellpadding="6" class="tabForm">
                
                <tr class="mangtableyellow">
                <th align="left" class="dataLabel" colspan="4">SELECT FILE TO IMPORT</th>
                </tr>
                <tr>
                <td class="mangtablewhite">
                <input type="hidden" />
                <input size="60" name="userfile" type="file"/>
                </td>
                </tr>
                <tr class="mangtablewhite"> 
                <td align="left"><p>
                  <input title="IMPORT" accessKey="" class="button" type="submit" name="button" value="Import"  onclick="return verify_data(this.form);">
                </p>
                  <p>&nbsp; </p></td>
                
                </tr>
                </table> </td></table>
                </form>
                </body>
                </html>
                

                geocoder1.php

                <?php
                
                if(isset($_GET['module']) && !empty($_GET['module'])) 
                {
                 $table='habitat_coupon_subscribers41';	
                
                	$target_path = '';
                	$csvfilename=$_FILES['userfile']['name'];
                
                	//echo $csvfilename; die;
                	$ext = substr(strrchr($csvfilename, '.\.'), 1);
                //echo $ext; die;
                		if($ext == "csv")
                		{
                			echo "it is a csv file ";
                
                	$client = new SoapClient(null, array( 
                                    "uri" => "http://rpc.geocoder.us/Geo/Coder/US/", 
                                    "location" => "http://geocoder.us/service/soap" 
                                    )); 
                
                $firstLineSkipped = false; 
                $inFileHandle = @fopen($csvfilename, "r"); 
                
                	if($outFileHandle = @fopen("results.csv", "w")) 
                	{ 
                		fclose($outFileHandle); 
                	}
                	$outFileHandle = @fopen("results.csv", "a"); 
                
                if ($inFileHandle && $outFileHandle) 
                { 
                    while (!feof($inFileHandle)) 
                    { 
                        $line = fgets($inFileHandle, 4096); 
                        if($firstLineSkipped) 
                        { 
                            $addressArray = explode(",", $line); 
                            $address = trim($addressArray[0], " \"\n\r"); 
                            $city = trim($addressArray[1], " \"\n\r"); 
                            $state = trim($addressArray[2], " \"\n\r"); 
                            $zip = trim($addressArray[3], " \"\n\r"); 
                
                        $fullAddress = $address . "," . $city . "," . $state . " " . $zip; 
                        print($fullAddress . "<br />"); 
                        try 
                        { 
                            $GeocoderResult = $client->geocode($fullAddress); 
                            if(count($GeocoderResult) > 0) 
                            { 
                                $latitude = $GeocoderResult[0]->lat; 
                                $longitude = $GeocoderResult[0]->long; 
                                $number = $GeocoderResult[0]->number; 
                                $street = $GeocoderResult[0]->street; 
                                $type = $GeocoderResult[0]->type; 
                                $city = $GeocoderResult[0]->city; 
                                $state = $GeocoderResult[0]->state; 
                                $zip = $GeocoderResult[0]->zip; 
                                $suffix = $GeocoderResult[0]->suffix; 
                                $outputLine = $number . " " . $street . " " . $type . " " . $suffix . "," . $city . "," . $state . " " . $zip . "," . $latitude . "," . $longitude . "\n"; 
                                fwrite($outFileHandle, $outputLine); 
                            } 
                        } 
                        catch (SoapFault $exception) 
                        { 
                            print("<pre>"); 
                            print($exception); 
                            print("<pre><br />"); 
                        } 
                        set_time_limit(30); 
                        sleep(2); 
                    } 
                    $firstLineSkipped = true; 
                } 
                fclose($inFileHandle); 
                fclose($outFileHandle); 
                } 
                
                	}else{
                	echo "not a csv file";
                	echo "<br>";
                	echo "<a href=geocoder2.php>Click here to go back</a>";
                	}
                
                
                }
                
                
                
                ?>
                
                  Write a Reply...