2011-11-28 46 views
0

我以前曾問過這個問題,但沒有很好地解釋它。我有一個處理表單地址的腳本,對其進行地理編碼並將其插入到數據庫中。地理編碼起作用,mysql查詢不起作用,郵件功能不起作用。我已經包含captca功能代碼,地理編碼代碼,插入語句和郵件功能。我也將添加pregmatch和「空」來檢查空字段。PHP地理編碼和插入

兩個圖形驗證碼和地理編碼工作,但插入和郵件沒有。

的問題 - else語句並不地理編碼後發揮作用。

注 - 地理編碼功能並不總是需要。這取決於表單的這一部分是否填寫完畢。有人提到過,地址代碼總是返回「true」,根據地址是否已經輸入,是否可以更改?

// Security code handling start 
include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php'; 
$securimage = new Securimage(); 
if ($securimage->check($_POST['captcha_code']) == false) { 
echo "The security code entered was incorrect.<br /><br />"; 
echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again."; 
exit; 
} 
// Security code handling finish 
// 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 (pricing, type, category, suggest, title, url, description, phone, fax, facebookpage, twitterpage, busemail, number, streetAddress, city, state, zip, country, name, email, latitude, longitude) 
VALUES ('$pricing', '$type', '$category', '$suggest', '$title', '$url', '$description', '$phone', '$fax', '$facebookpage', '$twitterpage', '$busemail', '$number', '$streetAddress', '$city', '$state', '$zip', '$country', '$name', '$email', '$lat', '$lon')"); 
} 
else {mail($email, "Your Submission", $message, $headers); 
header("Location: http://www.completepage.com"); 
    } 

如果任何人都可以請做出調整,將不勝感激。提前致謝。

回答

1

elseif後面有語法錯誤。請檢查語法...