在我使用 CakePHP 将数据保存到我的数据库之前,我正在尝试使用 mysql-real-escape-string 对输入进行清理。我收到以下错误
mysql_real_escape_string() [function.mysql-real-escape-string]:用户'nobody'@'localhost'的访问被拒绝(使用密码:否)
我的代码:
public function admin_videos($id = null) {
if(!($this->isLogged() && $this->isAuthorized())) {
$this->redirect(array('controller' => 'users', 'action' => 'login', 'admin' => true));
}
if ($this->request->is('post')) {
$this->request->data['MovieVideo']['video'] = mysql_real_escape_string($this->request->data['MovieVideo']['video']);
$this->request->data['MovieTrailer']['video'] = mysql_real_escape_string($this->request->data['MovieTrailer']['video']);
if ($this->Movie->saveAll($this->request->data)) {
$this->Session->setFlash('The movie has been saved', 'admin/flash_success');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('The movie could not be saved. Please, try again.', 'admin/flash_error');
}
} else {
$this->request->data = $this->Movie->find('first', array('conditions' => array('Movie.id' => $id), 'contain' => array('MovieTrailer', 'MovieVideo')));
}
}