本文介绍了数据在数据库中输入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我创建了一个表单,现在我想在数据库中提交它的数据。我有以下代码 <?php $ dbconn = new MySQLi( localhost, root, , Tajweed); { $ pname = mysqli_real_escape_string($ dbconn,$ _POST [' pname']); $ plink = mysqli_real_escape_string($ dbconn,$ _POST [' PLINK']); $ sql = $ dbconn-> query( INSERT INTO main_page(pname,plink)VALUES(' $ PNAME, '$ PLINK')); } ?> < 表格 name = myForm action = <?php $ _PHP_SELF?> 方法 = 发布 > 页面名称:< 输入 类型 = text 占位符 = 页面名称: 名称 = pname / > 页面链接:< 输入 type = text 占位符 = 页面链接: 名称 = plink / > < input type = 提交 value = 提交 > < / form > < pre lang = PHP > < 预 lang = PHP > 当我运行此代码时,它会给出错误 un-deafind index:pname和plink 请帮我解决问题。 我尝试了什么: $ dbconn =新的MySQLi(localhost,root,,Tajweed); { $ pname = mysqli_real_escape_string($ dbconn,$ _POST ['pname']); $ plink = mysqli_real_escape_string($ dbconn,$ _POST ['plink']); $ sql = $ dbconn-> query(INSERT INTO main_page(pname,plink)VALUES('$ pname' ,'$ plink')); } ?> < form name =myFormaction =method =post> 页面名称:<输入type =textplaceholder =page name:name =pname/> 页面链接:< input type =textplaceholder =Page Link:name =plink /> < input type =submitvalue =submit> < / form> i尝试此代码解决方案 dbconn = 新 MySQLi( localhost, root, , Tajweed); { pname = mysqli_real_escape_string( dbconn, I created a Form and now i want to submit it's data in the Database. i have the following code <?php$dbconn = new MySQLi("localhost","root","","Tajweed");{ $pname = mysqli_real_escape_string($dbconn, $_POST['pname']);$plink = mysqli_real_escape_string($dbconn, $_POST['plink']); $sql=$dbconn->query("INSERT INTO main_page (pname,plink) VALUES('$pname','$plink')");}?><form name="myForm" action="<?php $_PHP_SELF ?>" method="post">Page Name: <input type="text" placeholder="page name :" name="pname" />Page Link: <input type="text" placeholder="Page Link :" name="plink" /><input type="submit" value="submit"></form><pre lang="PHP"><pre lang="PHP">when i run this code it's give an error thatun-deafind index: "pname" and "plink"please help me to solve the problem.What I have tried:$dbconn = new MySQLi("localhost","root","","Tajweed");{ $pname = mysqli_real_escape_string($dbconn, $_POST['pname']);$plink = mysqli_real_escape_string($dbconn, $_POST['plink']); $sql=$dbconn->query("INSERT INTO main_page (pname,plink) VALUES('$pname','$plink')");}?><form name="myForm" action="" method="post">Page Name: <input type="text" placeholder="page name :" name="pname" />Page Link: <input type="text" placeholder="Page Link :" name="plink" /><input type="submit" value="submit"></form>i tried this code 解决方案 dbconn = new MySQLi("localhost","root","","Tajweed");{ pname = mysqli_real_escape_string(dbconn, 这篇关于数据在数据库中输入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-13 10:38