simpe php数据库连接无法连接数据库?
这是我的html代码simpe php数据库连接无法连接数据库?,php,Php,这是我的html代码 <?php include('process.php') ?> <!doctype html> <html lang="en"> <head> <title>Title</title> </head> <body> <from action="index.php.php" method="post"> <?php include(
<?php include('process.php') ?>
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<from action="index.php.php" method="post">
<?php include('errors.php'); ?>
<lable> name </lable>
<input type="text" name="name" placeholder="enter your name">
<lable>location</lable>
<input type="text" name="location" placeholder="enter your location">
<button type="submit" name="save_btn" >update</button>
</from>
</body>
</html>
标题
名称
位置
更新
这是我的php代码
<?php
session_start();
// initializing variables
$name="";
$location="";
// connect to the database
$db = mysqli_connect('localhost', 'newuser', 'password', 'curd');
// REGISTER USER
if (isset($_POST['save_btn'])) {
// receive all input values from the form
$name = mysqli_real_escape_string($db, $_POST['name']);
$location = mysqli_real_escape_string($db, $_POST['location']);
$query = "INSERT INTO data (name, location) VALUES('$name', '$location')";
mysqli_query($db, $query);
}
很好,问题似乎是由两个重要的打字错误引起的:
应该是
如果您有一些重要的打字错误,请在查看逻辑之前进行纠正:
应该是index.php.php
是表单提交到一个不存在的页面的问题,或者检查Addini\u set('display\u errors',1);ini_集(“日志错误”,1);错误报告(E_全部);mysqli_报告(mysqli_报告错误| mysqli_报告严格)代码>到脚本的顶部。这将强制任何mysqli_uu错误生成一个异常,您可以在浏览器上看到该异常以及正常的PHP错误。当您修复键入错误时:
应该是
。你不使用可以/会告诉你这些打字错误的IDE吗?这个问题应该结束,因为它只涉及一些打字错误,其他什么都没有。不要忘记结束表单标签
也应该是
,我们通常不会回答打字错误。我们只是做了一个有用的评论,正如你所做的,并投票关闭它。打字错误对任何人都没有用,这个问题很快就会被删除anyway@RiggsFolly谢谢,明白了