gpt4 book ai didi

php - Mysql通过函数INSERTing数据

转载 作者:行者123 更新时间:2023-11-30 22:12:46 25 4
gpt4 key购买 nike

<分区>

$con = mysqli_connect('localhost','root','',"z_db_test");
$tablename = 'test';
$about = 'Some info';
$firstname = 'Doe';
$lastname = 'Joe';

$datas = array('about'=>$about,'firstname'=>$firstname,'lastname'=>$lastname);

function addeverything($tablename,$datas)
{
$keys= array_keys($datas);
$insert = "INSERT INTO ".$tablename."
('`'.implode('`,`', $keys).'`')
VALUES(" '
".implode("
','
", $datas)."
'
") ";

return mysqli_query($insert);
}

addeverything('test',array('about'=>$about,'firstname'=>$firstname,'lastname'=>$lastname));

所以我得到了错误

Parse error: syntax error, unexpected ''".implode("'' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\test\index.php on line 20

如何修复错误?

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