PHP解析错误在> 0

时间:2013-04-03 15:01:06

标签: php parsing syntax-error

根本不是程序员。我被要求为我们的网站开发一个FTP页面,并发现看起来像是一些整齐的代码来使它工作。不幸的是(我使用的是Dreamweaver 6),看起来代码在第25行的“if(strleng($ error_message)> 0)”中断了......“我错过了什么?

<?php
$email_to='info@ispitfire.com';
$email_subject = "New file uploaded to FTP";
function died($error) {echo "There was an error uploading your file.";echo $error;die();}
if(!isset($_POST['theirname']) ||
!isset($_POST['email']) ||
!isset($_POST['audioname'])) {
died('Please make sure your name, email address, and the project name are completed.');
}
$theirname = $_POST['theirname'];
$email = $_POST['email'];
$audioname = $_POST['audioname'];
$comments = $_POST['comments'];
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {$error_message .= "Please input a valid email address.";
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$theirname)) {
$error_message .= "Please avoid using special characters.";
}
if(!preg_match($string_exp,$audioname)) {
$error_message .= "Please use only letters and numbers for Project Name.";
}
**if(strlen($error_message)>0){died($error_message);}clean_string($string){**
$bad = array("content-type","bbc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message = "A new file has been uploaded to the FTP site\n\n";
$email_message .= "Name: ".clean_string($theirname)."\n";
$email_message .= "Title: ".clean_string($audioname)."\n\n";
$email_message .= "Comments: ".clean_string($comments)."\n\n\n\n";
$headers = 'From: '.$email."\r\n";
if ($_FILES["file1"]["error"]>0) {
$email_message .= "Return Code: " . $_FILES["file1"]["error"] . "\n";
}
else
{
$email_message .= "Upload: " . $_FILES["file1"]["name"] . "\n";
$email_message .= "Type: " . $_FILES["file1"]["type"] . "\n";
$email_message .= "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb\n";
if ($_FILES["file1"]["type"] == "") {
if (file_exists("upload/" . $_FILES["file1"]["name"])) {
$email_message .= $_FILES["file1"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file1"]["tmp_name"],
"upload/" . $_FILES["file1"]["name"]);
$email_message .= "Stored in: " . "upload/" . $_FILES["file1"]["name"];
}
}
else
{
died("Unsupported file type.");
}
}
@mail($email_to, $email_subject, $email_message, $headers);
header('Location: ftp.html');
?>

这是我第一次涉足PHP,所以我真的不知道从哪里开始。似乎其他一切都正常工作,但由于该特定行上的某些内容,我无法使上传工作。

2 个答案:

答案 0 :(得分:2)

if(strlen($error_message)>0){died($error_message);}clean_string($string){
                                                   ^^^^^^^^^^^^^^^^^^^^^^^

您要么调用函数clean_string(),这意味着最后的{是错误的。如果你想尝试DEFINFE clean_string(),那么你就错过了function。  e.g。

if (...) { ... }
function clean_string($string) { ... }

if (...) {... }
clean_string($string);

答案 1 :(得分:0)

clean_string($string){应该做什么?

应该是if(clean_string($string)) {吗?

if(!clean_string($string)) {

或仅clean_string($string); {

或......?