gpt4 book ai didi

php - 向MySQL插入数据时500内部服务器

转载 作者:行者123 更新时间:2023-11-29 12:08:24 25 4
gpt4 key购买 nike

我试图通过将一些基本数据插入 MySQL 数据库来测试我的数据库,但我不断收到错误。在检查 Advanced Rest Client 后,它告诉我这是一个 500 内部服务器错误。我现在似乎无法弄清楚我做错了什么。这是我的 PHP 代码

<?php

//redacted password
$con = mysqli_connect("localhost", "root", "mypass", "user_data");

if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$firstname = "John";
$lastname = "Smith";
$email = "email@domain.com";
$password = "testpass";
$uuid = uniqid('', true);
$hash = $this->hashSSHA($password);
$encrypted_password = $hash["encrypted"]; // encrypted password
$salt = $hash["salt"]; // salt

$sql = mysqli_query($con, "INSERT INTO userinfo_basic(userid, firstname, lastname, email, encrypted_password, salt, created_at) VALUES('$uuid', '$firstname', '$lastname' '$email', '$encrypted_password', '$salt', NOW())");

if ($sql == true) {

echo "User Successfully Added!";

} else {

echo "User could not be added";

}



mysqli_close($con);

?>

如果我需要更改或添加任何内容,请询问。感谢所有帮助!

最佳答案

您在 '$lastname' 后面漏掉了一个逗号。

更改:

INSERT INTO userinfo_basic(userid, firstname, lastname, email, encrypted_password, salt, created_at) VALUES('$uuid', '$firstname', '$lastname' '$email', '$encrypted_password', '$salt', NOW())

致:

INSERT INTO userinfo_basic(userid, firstname, lastname, email, encrypted_password, salt, created_at) VALUES('$uuid', '$firstname', '$lastname', '$email', '$encrypted_password', '$salt', NOW())

关于php - 向MySQL插入数据时500内部服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31090321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com