[英]Unexpected $markerCount (T_VARIABLE)
不確定我在這里缺少什么。...我得到的錯誤是... 解析錯誤 :語法錯誤,在第8行的updateMarkerLocations.php中出現意外的'$ markerCount'(T_VARIABLE)
顯然$ markerCount是意外的嗎? 下面是我的全部代碼。 謝謝!
<?php
include 'db_const.php';
function insertMarkerLocations()
{
$markerCount = 0;
if (isset($_POST['markerCount'])
$markerCount = $_POST['markerCount']);
$con = mysql_connect($DB_HOST, $DB_USER, $DB_PASS );
if (!con) {
$msg = 'Could not connect to DB to save';
return $msg;
}
mysql_select_db($DB_NAME, $con);
$ID = $_POST['ID'];
for($i=0 ; $i < $markerCount; $i++){
$index = $i;
++$index;
$curMarkerID = $_POST["markerID$index"];
$curLang = $_POST["lang$index"];
$curLat = $_POST["lat$index"];
// Now write the current marker details in to the db.
$query = INSERT INTO userinfo (ID, markerID, lang, lat ) VALUES ('$ID', '$curMarkerID', '$curLang', '$curLat');
mysql_query($query)
or die(mysql_error());
}
$msg = "SUCCESS";
return $msg;
}
$msg = insertMarkerLocations();
echo json_encode($msg);
?>
這條線
if (isset($_POST['markerCount'])
$markerCount = $_POST['markerCount']);
應該
if (isset($_POST['markerCount']))
$markerCount = $_POST['markerCount'];
您在末尾有多余的肢體不適
$markerCount = $_POST['markerCount']);
刪除它並替換為以下內容:
$markerCount = $_POST['markerCount'];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.