这是我的代码,在写完所有内容并测试之后链接到另一个文件。我收到这个错误。我不确定如何解决它。
解析错误:语法错误,意外' {'在第11行的C:\ Sanjay \ Index.php
<?php
include_once("DB.php");
//make code insert image to database
if (isset($_POST['save']))
{
if(($_FILES['file']['type'] == 'image/gif')
||(($_FILES['file']['type'] == 'image/jpeg')
||(($_FILES['file']['type'] == 'image/pjpeg')
&& ($_FILES['file']['size'] < 2000000))
{
if ($_FILES['file']['error'] > 0)
{
echo "return code:" . $_FILES['file']['error'];
}
else if(file_exists('upload/'.$_FILES['file']['name']))
{
echo $_FILES['file']['name']."Already Exit";
}
else if (moved_uploaded_file($_FILES['file']['tmp_name'],
'upload/'.$_FILES['file']['name']))
{
$part = $_FILES['file']['name'];
$sql = mysql_query("INSERT INTO tblstudent
(studentname,gender,pob,address,status,photo)
VALUES('{$POST['studentname']}',
'{$POST['gender']}',
'{$POST['pob']}',
'{$POST['address']}',
'{$POST['status']}',
'{$part}')");
if ($sql)
{
echo "successfully insert this record.....";
}
}
}
}
//end
?>
答案 0 :(得分:4)
你错过了两个)
。试试这个
if(($_FILES['file']['type'] == 'image/gif')
||(($_FILES['file']['type'] == 'image/jpeg')
||(($_FILES['file']['type'] == 'image/pjpeg')
&& ($_FILES['file']['size'] < 2000000)
)
)
)
答案 1 :(得分:0)
似乎你错过了第10行的一个结束“)”。通常一个好主意,将复杂的语句(比如if中的那个)移动到单独的函数(它使代码更具可读性)。