我知道有一些与此相关的问题,但有c ++或其他语言.我收到此错误,我不确定我的功能有什么问题.
我的错误看起来像这样:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function User::register(), 2 passed in C:\xampp\htdocs\register.php on line 39 and exactly 5 expected in C:\xampp\htdocs\classes\users.php:22 Stack trace: #0 C:\xampp\htdocs\register.php(39): User->register('ds', 'dsssssss') #1 {main} thrown in C:\xampp\htdocs\classes\users.php on line 22
Run Code Online (Sandbox Code Playgroud)
我的功能是:
public function register($name, $surname, $username, $password, $email)
{
try {
$newPassword = password_hash($password, PASSWORD_DEFAULT);
$stmt = $this->conn->prepare("INSERT INTO user(name, surname, username, password, email)
VALUES(:name, :surname, :username, :password, :email)");
$stmt->bindParam(":name", $name);
$stmt->bindParam(":surname", $surname);
$stmt->bindParam(":username", $username);
$stmt->bindParam(":password", $password);
$stmt->bindParam(":password", $password);
$stmt->bindParam(":email", …Run Code Online (Sandbox Code Playgroud) 我试图根据这个搜索信息,但找不到任何有用的信息..我刚刚email sending在Yii2中创建,电子邮件发送为"我的应用程序",我想这是因为标准Yii::$app->name就是这样.有人能告诉我如何改变它吗?
有很多与此相关的答案,但我无法找到有用的信息。我试图连接到数据库并将用户输入的值插入数据库,但是出现此错误,我严重不知道自己在做什么错。我在2个不同的文件创建2个不同的类,一个是connection.php,另一个是users.php(用于insterting用户到数据库)有人能帮助我解决这个问题?
这里是我的connection.php文件:
<?php
class Connection {
public $dbh;
// Setting Database Source Name (DSN)
public function __construct() {
$dsn = 'mysql:host=localhost;dbname=employees';
// Setting options
$options = array (PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
// Making the connection to the database
try {
$this->dbh = new PDO($dsn, 'root', '', $options);
}
catch (PDOException $e) {
$this->error = $e->getMessage();
}
}
}
$connection = new connection();
?>
Run Code Online (Sandbox Code Playgroud)
这是我的users.php文件:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include 'connection.php';
class Users {
public $name;
public $surname;
public $employmentDate;
public $connection; …Run Code Online (Sandbox Code Playgroud) 我是 Yii2 的新手,我有 3 种user rights:
Admin,moderator和user。我有我的GridView,我不想向用户显示Update和Delete按钮,只显示GridView. 我该怎么做?
这是我的actionCreate,有一个输入表单:
public function actionCreate()
{
$model = new Project();
$model->scenario = Project::SCENARIO_CREATE;
if ($model->load(Yii::$app->request->post())) {
if ($model->save()) {
Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Skelbimas s?kmingai prid?tas!'));
return $this->redirect(['index']);
}
}
return $this->render('create', [
'model' => $model,
]);
}
Run Code Online (Sandbox Code Playgroud)
我试图根据this搜索信息,但找不到有用的信息。感谢您提供任何帮助或信息。