0

以前にこの質問をしたことがありますが、うまく説明できませんでした。フォームの住所を処理し、ジオコーディングしてデータベースに挿入するスクリプトがあります。ジオコーディングは機能しますが、mysql クエリは機能しません。また、メール機能も機能しません。Captca 関数コード、ジオコーディング コード、insert ステートメント、およびメール関数を含めました。空のフィールドをチェックするために pregmatch と "empty" も追加します。

キャプチャ コードとジオコードの両方が機能しますが、挿入物とメールは機能しません。

問題 - ジオコードの後、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" );
    }

どなたか調整していただけると助かります。前もって感謝します。

4

1 に答える 1

1

elseif の後に構文エラーがあります。構文を確認してください...

于 2011-11-28T01:20:21.350 に答える