gpt4 book ai didi

php - 从数据库中选择数据,然后再次插入数据库 codeigniter

转载 作者:行者123 更新时间:2023-11-29 11:43:35 24 4
gpt4 key购买 nike

嗨,我的图书馆有问题我想从数据库中选择数据,然后我想再次插入所选数据

这是我的代码

class Sms  {
function __construct() {
$ci = &get_instance();
}
function send($no,$msg,$username)
{
$ci = &get_instance();
$ci->load->model('log_model');
$host = "127.0.0.1";
$port = "8800";
$username = "admin";
$password = "";
$hp = $this->db->query('SELECT hp FROM t_akun');


$fp = fsockopen($host, $port, $errno, $errstr);
if (!$fp) {

"errno: $errno \n";
echo "errstr: $errstr\n";
return $result;
}

fwrite($fp, "GET /?Phone=".$no."&Text=" . rawurlencode($msg) . " HTTP/1.0\n");
if ($username != "") {
$auth = $username . ":" . $password;
$auth = base64_encode($auth);
fwrite($fp, "Authorization: Basic " . $auth . "\n");
}

fwrite($fp, "\n");

$res = "";

while(!feof($fp)) {
$res .= fread($fp,1);
}
fclose($fp);

$nolog = explode(',',$no);

date_default_timezone_set('Asia/Jakarta');
$now = date("Y-m-d H:i:s");
foreach($nolog as $row)
{
$data= array(
'username'=>$username,
'hp'=>$hp,
'act'=>'Send',
'd_log'=>$now
);
$ci->log_model->add_log($data);
}
if($res)
{
return $no;
}
}
}

那是代码错误

但是如果 $hp 更改为这样的代码,它就可以工作

$ci = &get_instance();
$ci->load->model('log_model');
$host = "127.0.0.1";
$port = "8800";
$username = "admin";
$password = "";
$hp = "12345678";

请帮助我:(

最佳答案

首先,您必须在CodeIgniter的View目录中创建一个PHP页面,其中使用CodeIgniter的语法创建一个表单。其次,您必须在 Controller 目录中创建类,在其中加载上述 PHP 页面( View ),对表单字段应用验证并加载相应的模型。第三,对于应用程序中的数据库连接,在模型目录中创建一个具有数据库插入功能的类。

Cehek 这个网站可能会有用。 http://www.formget.com/insert-data-into-database-using-codeigniter/

关于php - 从数据库中选择数据,然后再次插入数据库 codeigniter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35343236/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com