不确定我在这里失踪了......我得到的错误是...... 解析错误:语法错误, 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);
?>
答案 0 :(得分:2)
这一行
if (isset($_POST['markerCount'])
$markerCount = $_POST['markerCount']);
应该是
if (isset($_POST['markerCount']))
$markerCount = $_POST['markerCount'];
答案 1 :(得分:0)
末尾有一个不需要的括号
$markerCount = $_POST['markerCount']);
将其删除并替换为以下内容:
$markerCount = $_POST['markerCount'];