简体   繁体   English

无法使用PHP 5.5将数据添加到webmatrix 3中的MySQL 5.7

[英]unable to use PHP 5.5 to add data to MySQL 5.7 in webmatrix 3

Please help, this is driving me mad! 请帮忙,这让我很生气! I have, I thought, a simple registration form that I am trying to send data with PHP to MySQL in Webmatrix. 我想,我有一个简单的注册表单,我试图用PHP将数据发送到Webmatrix中的MySQL。 (PHP 5.5 to add data to MySQL 5.7 in webmatrix 3) however, I get the following error in Chrome: (PHP 5.5将数据添加到webmatrix 3中的MySQL 5.7),但是在Chrome中出现以下错误:

The localhost page isn't working localhost is currently unable to handle this request. localhost页面无法正常工作localhost目前无法处理此请求。 500 500

Here's the PHP: 这是PHP:

<?php
$db_user = 'root';
$db_pass = '';

$db_name = 'MySQL10';
$db_host = 'localhost';

$fname = $_POST('fname')
$lname = $_POST('lname')
$email = $_POST('email')

//Create Connection
$conn = new mysqli ( $db_host, $db_user, $db_pass, $db_name);

//Check connection
 if ($conn->connect_error) {
    die("Connection failed:" . $conn->connect_error);
}

$sql = "INSERT INTO table_1 (fname_1, lname_1, email_1)
VALUES ('$fname', '$lname', '$email')";

$conn->close();

?>

Here's Mark up: 这是标记:

<!DOCTYPE html>



<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Test Page</title>

    </head>

<body>

<div class="registration">
  <form name="test" method="post" action="demo.php" autocomplete="on">      
      <p>First name:<input type="text" name="fname" value=""></p>
      <p>Last name:<input type="text" name="lname" value=""></p>
      <p>Email Address:<input type="email" name="email" value=""></p>
      <input type="submit" value="Submit">
  </form>         
</div>    
</body>

</html>

thank you all. 谢谢你们。 I added the [] and the ; 我加了[]和; and having checked the input using: if ($conn->query($sql) === TRUE) { echo "New record created successfully"; 并使用以下命令检查了输入:if($ conn-> query($ sql)=== TRUE){echo“成功创建新记录”; } else { echo "Error: " . } else {echo“错误:”。 $sql . $ sql。 "
" . $conn->error; } i was kindly reminded that I had not set a default value for the ID in the database! “。$ conn-> error;}提醒我,我没有为数据库中的ID设置默认值!

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

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