【发布时间】:2011-05-13 23:03:09
【问题描述】:
尝试执行 php 文件时,在本地 MAMP 服务器上收到 HTTP 错误 500。
我所有的其他页面都会运行,但是这个不会,所以我认为这可能与 php 设置有关?
<?php
// User.class.php
require_once 'DB.class.php';
class User {
public $id;
public $username;
public $hashedPassword;
public $email;
public $joinDate;
// Takes an associative array with the DB row as an argument.
function __construct($data) {
$this->id = (isset($data['id'])) ? $data['id'] : "";
$this->username = (isset($data['username'])) ? $data['username'] : "";
$this->hashedPassword = (isset($data['password'])) ? $data['password'] : "";
$this->email = (isset($data['email'])) ? $data['email'] : "";
$this->joinDate = (isset($data['join_date'])) ? $data['join_date'] : "";
}
public function save($isNewUser = false) {
$db = new DB();
// Update already registered user.
if (!$isNewUser) {
$data = array(
"username" => "'$this->username'";
"password" => "'$this->hashedPassword'";
"email" => "'$this->email'";
);
$db->update($data, 'users', 'id = '.$this->id);
}
// Register new user.
else {
$data = array(
"username" => "'$this->username'";
"password" => "'$this->hashedPassword'";
"email" => "'$this->email'";
"join_date" => "'".date("Y-m-d H:i:s", time())."'"
);
$this->id = $db->insert($data, 'users');
$this->joinDate = time();
}
return true;
}
}
?>
PHP 错误日志:
[13-May-2011 23:58:28] PHP Parse error: syntax error, unexpected ';', expecting ')' in /Applications/MAMP/htdocs/Project/classes/User.class.php on line 35
【问题讨论】:
-
在您的 Apache error.log 中说什么是 500 错误的原因?如果您不明白它在告诉您什么,请将其粘贴到您的原始问题中...