Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter模型未插入值_Php_Mysql_Database_Codeigniter_Crud - Fatal编程技术网

Php Codeigniter模型未插入值

Php Codeigniter模型未插入值,php,mysql,database,codeigniter,crud,Php,Mysql,Database,Codeigniter,Crud,这是我在CI中的第二个web应用程序 我试图从表单(提交时)中获取一个值并将其插入数据库 我有一个控制器“urlsubmission”: 我做错了什么?您没有运行SQL查询。这样做 $newDomain = "INSERT INTO ClientDomain(tld) VALUES('".$this->db->escape_str($postedTLD)."')"; $this->db->query($newDomain); 或者可以使用简单的查询() 您声明了INSE

这是我在CI中的第二个web应用程序

我试图从表单(提交时)中获取一个值并将其插入数据库

我有一个控制器“urlsubmission”:


我做错了什么?

您没有运行SQL查询。这样做

$newDomain = "INSERT INTO ClientDomain(tld) VALUES('".$this->db->escape_str($postedTLD)."')";
$this->db->query($newDomain);
或者可以使用简单的查询()


您声明了INSERT语句,但从未执行过它?

很好,我知道我做错了什么。我真傻。谢谢@Cryptic!
<?php

    class Domaincheckmodel extends CI_Model{

        function __construct(){
            // Call the Model constructor
            parent::__construct();
        }


        function verifyduplicates(){
            #PREPARE DATA
            $sql = "SELECT tld from ClientDomain WHERE tld = ?";
            $postedTLD = $_POST['urlInput'];    // Get unsanitized data
            $endquery = $this->db->query($sql,array($this->db->escape_str($postedTLD))); // Query db

            #CONDITION
            if($endquery->num_rows() > 0){
                $this->load->view('err/domainexists'); ##domain already used
                ## please login..
            } 

            else{ #number of rows must be 0, insert into db
                $newDomain = "INSERT INTO ClientDomain(tld) VALUES('".$this->db->escape_str($postedTLD)."')";
                $this->load->view('success/domainfree');
                ## please register
            }
        }    
    }

    ?>
<h2>Domain Exists</h2>
<h2>Domain free</h2>
$autoload['libraries'] = array('database');
$newDomain = "INSERT INTO ClientDomain(tld) VALUES('".$this->db->escape_str($postedTLD)."')";
$this->db->query($newDomain);
$newDomain = "INSERT INTO ClientDomain(tld) VALUES('".$this->db->escape_str($postedTLD)."')";
$this->db->simple_query($newDomain);