我有一份工作登记表,但我不知怎的搞砸了。 我在移动上传行中遇到此错误,我真的不知道如何解决它,因为它正在工作,我没有特别改变该行。
解析错误:语法错误,意外''',期待标识符 (T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING)in 第18行/home/nel/public_html/test/process.php
<?php
include "config.php";
$name = $_POST['name'];
$school= $_POST['school'];
$email = $_POST['email'];
$grad_year = $_POST['gradYear'];
$hardware = $_POST['hardware'];
$type = $_FILES["file"]["type"];
if(empty($name) || empty($school) || empty($email) || empty($grad_year) || !filter_var($email, FILTER_VALIDATE_EMAIL))
{
echo "You did not fill out the required fields correctly. Please try again!";
}
else{
$insert = "INSERT INTO hackers VALUES('$name','$email','$school','$grad_year’,’$hardware’)”;
move_uploaded_file($_FILES["file"]["tmp_name"], "/home/nel/resumes/" . $_FILES["file"]["name"]);
echo "Thank you for registering!”;
echo $name= $_Files['file']['name'];
$conn->query($insert);
}
?>
答案 0 :(得分:2)
您在'$grad_year’,’$hardware’
使用了刻度而不是单引号。改变它,你的错误应该消失。
此外,您应该使用预备声明。它更安全,更易读。
答案 1 :(得分:0)
如下所示进行更改,也请参阅我的评论
$insert = "INSERT INTO hackers VALUES('$name','$email','$school','$grad_year','$hardware')"; // change here
move_uploaded_file($_FILES["file"]["tmp_name"], "/home/nel/resumes/" . $_FILES["file"]["name"]);
echo "Thank you for registering!"; // change here