주소에서 위도와 경도를 검색하고 SQL 데이터베이스에 삽입하는 if 문이 있습니다. 양식의 기본 구조는 가지고 있지만 빈 필드 검사 및 pregmatch를 포함 시키길 원합니다. 그러나 if else 문을 입력하면 아무 일도 일어나지 않습니다.PHP else 문을 무시하면 무시
// Your Google Maps API key
$key = "key";
// Desired address
$address = 'http://maps.google.com/maps/geo?q='.$location.'&output=json&oe=utf8&sensor=false&key=$key';
// Retrieve the URL contents
$data = file_get_contents($address);
// Parse the returned XML file
$jsondata = json_decode($data,true);
if (is_array($jsondata)&& $jsondata ['Status']['code']==200){
$lat = $jsondata ['Placemark'][0]['Point']['coordinates'][0];
$lon = $jsondata ['Placemark'][0]['Point']['coordinates'][1];
}
elseif (mysql_query("INSERT INTO database (type, category, suggest, title, url, description, phone, fax, facebookpage, twitterpage, busemail, number, streetAddress, city, state, zip, country, name, email, latitude, longitude)
VALUES ('$type', '$category', '$title', '$url', '$description', '$phone', '$fax', '$facebookpage', '$twitterpage', '$busemail', '$number', '$streetAddress', '$city', '$state', '$zip', '$country', '$name', '$email', '$lat', '$lon')"); {
die(header ("Location: http://www.exampleerrorpage.com") . mysql_error());
}
else { mail($email, "Subject", $message, $headers);
header("Location: http://www.examplecomplete.com/");
}
미리 도움을 청하십시오.
편집은 PHP에 대한 기본 지식 만 갖고 있으며 여전히 초보자입니다. 젠틀. 다시 한번 감사드립니다.
EDIT - 양식의 주소 부분이 항상 존재하지 않을 수 있습니다. 따라서 지오 코드가 항상 실행될 필요는 없습니다.
귀하의 질문은 전혀 분명하지 않다 :
는 논리 - 현명한, 당신은 아마의 라인을 따라 뭔가를 원한다. 코드와 함께 시도하고있는 것, 일어날 것으로 예상되는 것, 실제로 일어나는 것을 설명하십시오. –
실례합니다. 어떻게 그것을 무시하고 있습니까? condition이 'TRUE'이면 if가 실행되고, 그렇지 않으면'ELSE'가 실행됩니다. 그래서 ELSE가 실행되고 있지 않다면 IF 문이 실행 되었기 때문입니다. – gustavotkg
PHP는 * 아무것도 * 무시하지 않습니다. 논리 오류가 발생했을 뿐이므로 오류가없는 버전을 보여주기 때문에 도움을받을 수 없습니다. – deceze