我有一个包含以下 php 代码的文件:
<?php
session_start();
include_once("config.php");
include_once("functions.php");
include_once("class/db.class.php");
$config = new config($db_host, $db_user, $db_pass, $db_name);
$db = new db($config);
$db->openConnection();
switch ($_POST['mode']) {
case 'update':
if(mysql_query("UPDATE table_name SET id_negozio = '".$_POST['negid']."', nome='".mysql_real_escape_string(strtolower($_POST['nome']))."', cognome='".mysql_real_escape_string(strtolower($_POST['cognome']))."', indirizzo='".mysql_real_escape_string($_POST['indirizzo'])."', CAP='".$_POST['cap']."', city='".mysql_real_escape_string($_POST['city'])."', tel='".$_POST['tel']."', email='".strtolower($_POST['email'])."', provincia='".strtoupper($_POST['provincia'])."', data_nascita = '".$_POST['datanascita']."', luogo_nascita='".mysql_real_escape_string($_POST['luogonascita'])."', doc_number='".strtoupper($_POST['docnum'])."', doc_type='".$_POST['doctype']."', doc_data='".$_POST['docdata']."', cf='".strtoupper($_POST['cf'])."', doc_exp='".$_POST['doc_exp']."', doc_rilascio='".$_POST['doc_rilascio']."' WHERE id = ".$_POST['id']." ")){
echo "ok";
}
break;
case 'salvataggio_finale':
if(mysql_query("UPDATE table_name SET salvato = 1 WHERE id = ".$_POST['id']." ")){
logit("Creato nuovo cliente.", $_POST['idneg']);
echo "ok";
}
break;
case 'del':
if(mysql_query("DELETE FROM table_name WHERE id = ".$_POST['id']." ")){
logit("Eliminato cliente con id ".$_POST['id']."", $_POST['idneg']);
echo "deleted";
}
break;
}
unset($db);
?>
在我的服务器上,我有 error_log 显示 38 个给出此错误的条目:
[..] PHP Parse error: syntax error, unexpected '{' in /home/.../filename.php on line 12
第 12 行是case 'update'之后的if 语句, 我不明白为什么我不应该放括号或真正的错误是什么。