pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <legend id='gvPPx'><style id='gvPPx'><dir id='gvPPx'><q id='gvPPx'></q></dir></style></legend>

    <tfoot id='gvPPx'></tfoot>

      <small id='gvPPx'></small><noframes id='gvPPx'>

      <i id='gvPPx'><tr id='gvPPx'><dt id='gvPPx'><q id='gvPPx'><span id='gvPPx'><b id='gvPPx'><form id='gvPPx'><ins id='gvPPx'></ins><ul id='gvPPx'></ul><sub id='gvPPx'></sub></form><legend id='gvPPx'></legend><bdo id='gvPPx'><pre id='gvPPx'><center id='gvPPx'></center></pre></bdo></b><th id='gvPPx'></th></span></q></dt></tr></i><div class="zfzx7bp" id='gvPPx'><tfoot id='gvPPx'></tfoot><dl id='gvPPx'><fieldset id='gvPPx'></fieldset></dl></div>
        <bdo id='gvPPx'></bdo><ul id='gvPPx'></ul>

      1. mysqli 插入 - 但前提是不重復

        mysqli insert - but only if not a duplicate(mysqli 插入 - 但前提是不重復)
          <tbody id='mk7eJ'></tbody>

          <tfoot id='mk7eJ'></tfoot>
          <i id='mk7eJ'><tr id='mk7eJ'><dt id='mk7eJ'><q id='mk7eJ'><span id='mk7eJ'><b id='mk7eJ'><form id='mk7eJ'><ins id='mk7eJ'></ins><ul id='mk7eJ'></ul><sub id='mk7eJ'></sub></form><legend id='mk7eJ'></legend><bdo id='mk7eJ'><pre id='mk7eJ'><center id='mk7eJ'></center></pre></bdo></b><th id='mk7eJ'></th></span></q></dt></tr></i><div class="t5njnzn" id='mk7eJ'><tfoot id='mk7eJ'></tfoot><dl id='mk7eJ'><fieldset id='mk7eJ'></fieldset></dl></div>
          • <small id='mk7eJ'></small><noframes id='mk7eJ'>

            • <bdo id='mk7eJ'></bdo><ul id='mk7eJ'></ul>

                <legend id='mk7eJ'><style id='mk7eJ'><dir id='mk7eJ'><q id='mk7eJ'></q></dir></style></legend>

                1. 本文介紹了mysqli 插入 - 但前提是不重復的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我是一名 Java 開發(fā)人員,剛剛完成了一些快速簡單的數(shù)據(jù)庫工作"的任務——除了我對 PHP/MySQL 不太了解……我需要將記錄插入到數(shù)據(jù)庫中——但只有如果電子郵件字段與數(shù)據(jù)庫中已存在的字段不匹配.到目前為止,我收集到的 PHP 代碼如下:

                  I'm a Java developer who just got handed the task of "some quick easy DB stuff" - except I don't know much about PHP/MySQL...I need to insert a record into a DB - but only if the email field doesn't match one that already exists in the DB. Here's what I've gleaned so far for my PHP code:

                  // Grab the values from the HTML form:
                  $newUserName = $_POST['newUserName'];
                  $newUserName = $mysqli->real_escape_string($newUserName);
                  $newUserEmail = $_POST['newUserEmail'];
                  $newUserEmail = $mysqli->real_escape_string($newUserEmail);
                  
                  // Now search the DB to see if a record with this email already exists:
                  $mysqli->query("SELECT * FROM RegisteredUsersTable WHERE UserEmail = '$newUserEmail'");
                  

                  現(xiàn)在我需要查看是否有任何內容從該搜索中返回 - 這意味著電子郵件已經存在 - 如果是,我需要提醒用戶,否則我可以繼續(xù)使用:

                  Now I need to see if anything came back from that search - meaning the email already exists - and if so I need to alert the user, otherwise I can go ahead and insert the new info into the DB using:

                  $mysqli->query("INSERT INTO RegisteredUsersTable (UserName, UserEmail) VALUES ('".$newUserName."', '".$newUserEmail."')");
                  

                  有什么想法嗎?

                  推薦答案

                  根據(jù)您的代碼工作,這應該為您指明正確的方向.也許有更好的方法來構建您的數(shù)據(jù)庫,以便更好地利用它.

                  Working from your code, this should point you in the right direction. there are, perhaps, better ways to structure your database that will make better use of it.

                  <?php
                  
                  $mysqli = new mysqli("localhost", "iodine", "iodine","iodine");
                  
                  // Grab the values from the HTML form:
                  /*
                  $newUserName = $_POST['newUserName'];
                  $newUserName = $mysqli->real_escape_string($newUserName);
                  $newUserEmail = $_POST['newUserEmail'];
                  $newUserEmail = $mysqli->real_escape_string($newUserEmail);
                  */
                  $newUserName = "Test User";
                  $newUserEmail = "test4@example.com";
                  
                  // Now search the DB to see if a record with this email already exists:
                  echo "SELECT * FROM RegisteredUsersTable WHERE UserEmail = '$newUserEmail'", "
                  ";
                  $result = $mysqli->query("SELECT * FROM RegisteredUsersTable WHERE UserEmail = '$newUserEmail'");
                  
                  if (!$result) {
                    die($mysqli->error);
                  }
                  echo "num_rows = ".$result->num_rows."
                  ";
                  if ($result->num_rows > 0) {
                     echo "Duplicate email
                  ";
                     // do something to alert user about non-unique email
                  } else {
                    $result = $mysqli->query("INSERT IGNORE INTO RegisteredUsersTable (UserName, UserEmail) VALUES ('".$newUserName."', '".$newUserEmail."')");
                    if ($result === false) {echo "SQL error:".$mysqli->error;}
                  }
                  
                  ?>
                  

                  這篇關于mysqli 插入 - 但前提是不重復的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數(shù) mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)

                    1. <i id='Bbf8K'><tr id='Bbf8K'><dt id='Bbf8K'><q id='Bbf8K'><span id='Bbf8K'><b id='Bbf8K'><form id='Bbf8K'><ins id='Bbf8K'></ins><ul id='Bbf8K'></ul><sub id='Bbf8K'></sub></form><legend id='Bbf8K'></legend><bdo id='Bbf8K'><pre id='Bbf8K'><center id='Bbf8K'></center></pre></bdo></b><th id='Bbf8K'></th></span></q></dt></tr></i><div class="bfjzlhh" id='Bbf8K'><tfoot id='Bbf8K'></tfoot><dl id='Bbf8K'><fieldset id='Bbf8K'></fieldset></dl></div>

                      <small id='Bbf8K'></small><noframes id='Bbf8K'>

                        <tbody id='Bbf8K'></tbody>

                            <bdo id='Bbf8K'></bdo><ul id='Bbf8K'></ul>

                            <tfoot id='Bbf8K'></tfoot>
                            <legend id='Bbf8K'><style id='Bbf8K'><dir id='Bbf8K'><q id='Bbf8K'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 郑州墨香品牌设计公司|品牌全案VI设计公司 | 河南道路标志牌_交通路标牌_交通标志牌厂家-郑州路畅交通 | 氮化镓芯片-碳化硅二极管 - 华燊泰半导体 | 展厅设计-展馆设计-专业企业展厅展馆设计公司-昆明华文创意 | 知企服务-企业综合服务(ZiKeys.com)-品优低价、种类齐全、过程管理透明、速度快捷高效、放心服务,知企专家! | 压滤机-洗沙泥浆处理-压泥机-山东创新华一环境工程有限公司 | 开云(中国)Kaiyun·官方网站 - 登录入口 | 定硫仪,量热仪,工业分析仪,马弗炉,煤炭化验设备厂家,煤质化验仪器,焦炭化验设备鹤壁大德煤质工业分析仪,氟氯测定仪 | 华中线缆有限公司-电缆厂|电缆厂家|电线电缆厂家 | 金属清洗剂,防锈油,切削液,磨削液-青岛朗力防锈材料有限公司 | 无锡网站建设_小程序制作_网站设计公司_无锡网络公司_网站制作 | 真空乳化机-灌装封尾机-首页-温州精灌| 煤机配件厂家_刮板机配件_链轮轴组_河南双志机械设备有限公司 | 混合气体腐蚀试验箱_盐雾/硫化氢/气体腐蚀试验箱厂家-北京中科博达 | 退火炉,燃气退火炉,燃气热处理炉生产厂家-丹阳市丰泰工业炉有限公司 | 除湿机|工业除湿机|抽湿器|大型地下室车间仓库吊顶防爆除湿机|抽湿烘干房|新风除湿机|调温/降温除湿机|恒温恒湿机|加湿机-杭州川田电器有限公司 | 粉丝机械,粉丝烘干机,粉丝生产线-招远市远东粉丝机械有限公司 | 变压器配件,变压器吸湿器,武强县吉口变压器配件有限公司 | 阻垢剂-反渗透缓蚀阻垢剂厂家-山东鲁东环保科技有限公司 | 振动筛,震动筛,圆形振动筛,振动筛价格,振动筛厂家-新乡巨宝机电 蒸汽热收缩机_蒸汽发生器_塑封机_包膜机_封切收缩机_热收缩包装机_真空机_全自动打包机_捆扎机_封箱机-东莞市中堡智能科技有限公司 | 南京兰江泵业有限公司-水解酸化池潜水搅拌机-絮凝反应池搅拌机-好氧区潜水推进器 | 砂尘试验箱_淋雨试验房_冰水冲击试验箱_IPX9K淋雨试验箱_广州岳信试验设备有限公司 | 老房子翻新装修,旧房墙面翻新,房屋防水补漏,厨房卫生间改造,室内装潢装修公司 - 一修房屋快修官网 | 冰晶石|碱性嫩黄闪蒸干燥机-有机垃圾烘干设备-草酸钙盘式干燥机-常州市宝康干燥 | 蓝莓施肥机,智能施肥机,自动施肥机,水肥一体化项目,水肥一体机厂家,小型施肥机,圣大节水,滴灌施工方案,山东圣大节水科技有限公司官网17864474793 | 板框压滤机-隔膜压滤机-厢式压滤机生产厂家-禹州市君工机械设备有限公司 | 艺术涂料_进口艺术涂料_艺术涂料加盟_艺术涂料十大品牌 -英国蒙太奇艺术涂料 | 刹车盘机床-刹车盘生产线-龙口亨嘉智能装备 | 安徽华耐泵阀有限公司-官方网站 安德建奇火花机-阿奇夏米尔慢走丝|高维|发那科-北京杰森柏汇 | 聚天冬氨酸,亚氨基二琥珀酸四钠,PASP,IDS - 远联化工 | 线材成型机,线材折弯机,线材成型机厂家,贝朗自动化设备有限公司1 | 锥形螺带干燥机(新型耙式干燥机)百科-常州丰能干燥工程 | 威廉希尔WilliamHill·足球(中国)体育官方网站 | 粉末包装机,拆包机厂家,价格-上海强牛包装机械设备有限公司 | 全国冰箱|空调|洗衣机|热水器|燃气灶维修服务平台-百修家电 | nalgene洗瓶,nalgene量筒,nalgene窄口瓶,nalgene放水口大瓶,浙江省nalgene代理-杭州雷琪实验器材有限公司 | 除湿机|工业除湿机|抽湿器|大型地下室车间仓库吊顶防爆除湿机|抽湿烘干房|新风除湿机|调温/降温除湿机|恒温恒湿机|加湿机-杭州川田电器有限公司 | 铸钢件厂家-铸钢齿轮-减速机厂家-淄博凯振机械有限公司 | 铁艺,仿竹,竹节,护栏,围栏,篱笆,栅栏,栏杆,护栏网,网围栏,厂家 - 河北稳重金属丝网制品有限公司 山东太阳能路灯厂家-庭院灯生产厂家-济南晟启灯饰有限公司 | 石家庄网站建设|石家庄网站制作|石家庄小程序开发|石家庄微信开发|网站建设公司|网站制作公司|微信小程序开发|手机APP开发|软件开发 | PCB设计,PCB抄板,电路板打样,PCBA加工-深圳市宏力捷电子有限公司 |