我正在编写一些 PHP 代码以将 CSV 文件导入 Postgre DB,但出现以下错误。你能帮助我吗?
警告:pg_end_copy():查询失败:错误:在数据中找到文字换行符提示:使用“\n”表示换行符。上下文:复制 t_translation,C:\xampp\htdocs\importing_csv\importcsv.php 中的第 2 行,第 21 行
<?php
$connString = 'host = localhost dbname= importdb user=postgres password=pgsql';
$db = pg_connect($connString);
$file = file('translation.csv');
//pg_exec($db, "CREATE TABLE t_translation (id numeric, identifier char(100), device char(10), page char(40), english char(100), date_created char(30), date_modified char(30), created_by char(30), modified_by char(30) )");
pg_exec($db, "COPY t_translation FROM stdin");
foreach ($file as $line) {
$tmp = explode(",", $line);
pg_put_line($db, sprintf("%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", $tmp[0], $tmp[1], $tmp[2], $tmp[3], $tmp[4], $tmp[5], $tmp[6], $tmp[7], $tmp[8]));
}
pg_put_line($db, …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我怎么能为我的行添加一个标识符.我有这个代码使用json数据填充表体.
var table = '';
$.each(result, function (i, item) {
table += '<tr class="test"><td>' + item.ip_address + '</td><td>' + item.app_name + '</td><td>' + item.crit_severity + '</td><td>' + item.user_password + '</td></tr>';
});
$("#tableLinks tbody").html(table);
Run Code Online (Sandbox Code Playgroud)
我有这张桌子
<table class="table table-bordered" id="tableLinks" style="width:70%;margin">
<thead>
<tr>
<th>IP ADDRESS</th>
<th>APPLICATION NAME</th>
<th>CRIT/SEVERITY</th>
<th>USERNAME/PASSWORD</th>
</tr>
</thead>
<tbody>
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)
我使用此代码进行测试,但它不起作用.这可能是什么错误?谢谢
$(".test").on('click', function() {
alert('test');
});
Run Code Online (Sandbox Code Playgroud)