当前位置:网站首页>php向mysql写入数据失败
php向mysql写入数据失败
2022-08-06 05:11:00 【CSDN问答】
php向mysql写入数据失败,弄了好久都弄不出来。看看问题在哪
html:代码
html><html> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/out/water.min.css"/> <title>
title>
head> <body> <form action="formData.php" method="get"> <label>姓名:
label><input type="text" name="user"/><br> <label>密码:
label><input type="password" name="pass"><br> <input type="submit" value="注册"/>
form>
body>
html>php:代码:
$user=$_GET['user'];$pass=$_GET['pass'];$db_host="localhost";$db_name="root";$db_pwd="";$link=mysqli_connect($db_host,$db_name,$db_pwd) ;//2.判断是否成功if ($link){echo"success";}else {echo"fail";}//3.设置字符集mysqli_set_charset($link,"utf8");//4.选择数据库mysqli_select_db($link,"lhy");$sql = "use lhy;";$sql += "INSERT into ifm(name,password) values ('$user','$pass');";if ($link->query($sql) === TRUE) {echo"新记录插入成功";} else {echo " Error:".$sql."
".$link->error;}数据库:

运行结果:

边栏推荐
- 环境敏感性/温核磁共振/载生长素/载细胞膜/载蛋白质水凝胶的研究
- “模组+天线”全栈解决方案,提速物联网终端高效部署
- 牛客题目——买卖股票的最好时机(一)、(二)、(三)、设计LRU缓存结构
- 互联网时代下服务器该如何进行主机加固
- Comprehensive review materials for "Public Relations"
- 《论文阅读》EmpTransfo: A Multi-head Transformer Architecture for Creating Empathetic Dialog Systems
- 牛刀小试基本语法,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang基本语法和变量的使用EP02
- 7. Building RESTful Services
- 重发布中的路由策略:
- 2023年第六届先进控制,自动化与机器人国际会议(ICACAR 2023)
猜你喜欢

为什么double = 5 / 9; 的结果为零

What are the application scenarios of LoRa technology?

Backup and restore Etcd data in a Kubernetes cluster

如何保持注意力,高效学习

Translation recommendation|In-depth analysis of BookKeeper protocol model and verification

fegin feign.FeignException: status 404 reading StudenService#getAll()

备份和恢复Kubernetes集群中的Etcd数据

互联网时代下服务器该如何进行主机加固

WindowsServer下配置Mysql主从同步---Mysql主从复制同步001

字节跳动 Flink 状态查询实践与优化
随机推荐
Discrete mathematics the final problem
$nextTick 原理及作用
信息系统项目管理师必背核心考点(六十一)项目组合概念
defineProperty 和 proxy 的区别
MySQL - MySQL 常用存储引擎简介
A first look at the code to start, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, the first time to run the golang program EP01
响应式织梦模板潜水游泳类网站
MySQL - MySQL 三范式理解
动态路由协议的分类、动静态路由优缺点、RIP简介、组播单播广播详解(附图)
工业机器人复习重点
Solve the error: DispatcherServlet is popular!!
web漏洞扫描器-appscan
Practical and bytes to beat Flink status query optimization
金属材料/多肽/多糖/化合物/抗体/量子点/黑磷量子点修饰水凝胶
js实现数组分成每5个对象一组的新数组
数据库系统原理与应用教程(079)—— MySQL 练习题:操作题 181-185(二十三):综合练习
Uniapp static file is too large solution
响应式织梦模板金属丝网类网站
gst-launch-1.0
单区域——OSPF 讲解+配置命令(为了做双机热备实验)