简体   繁体   English

在将数据插入MySQL时使用500内部服务器

[英]500 Internal Server when Inserting data to MySQL

I am attempting to test my database by inserting some basic data into a MySQL database, but I keep getting an error. 我试图通过将一些基本数据插入MySQL数据库来测试我的数据库,但是我一直遇到错误。 After checking with Advanced Rest Client, it tells me it's a 500 Internal Server Error . 与Advanced Rest Client检查后,它告诉我这是500 Internal Server Error I can't seem to figure out what i'm doing wrong at this point. 我似乎无法弄清楚我现在在做什么错。 This is my PHP Code 这是我的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);

?>

If there's anything I need to change or add, please ask. 如果我需要更改或添加任何内容,请询问。 All Help is appreciated! 感谢所有帮助!

You've missed a comma after '$lastname' . 您错过了'$lastname'之后的逗号。

Change: 更改:

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

To: 至:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM