php - 如何通过 SQL 将文本中的撇号发送到 DB2
问题描述
在 Zend Server 上,我们已经升级到 PHP 7,它破坏了一个 PHP 脚本。用户可以将文档中的文本粘贴到文本区域,然后通过 SQL 将其发送到 DB2 文件。在 PHP 7 之前,我使用它来确保发送撇号...
$lineout = ereg_replace("'", "''", $line[$a]);
当然,这已被弃用,我将其替换为...
$lineout = preg_replace("/'/", "/''/", $line[$a]);
现在脚本只将文本发送到第一个带有撇号的单词。我已经玩了一段时间了,必须寻求帮助。建议?
我查看了 db2_prepared 语句,但仍然没有得到我要查找的撇号。正在使用的代码的更新...
if ($b < 999) {
$conn = db2_connect($_SESSION['i5'] , decode($_SESSION['def_user'],
$_SESSION['key']), decode($_SESSION['def_pwd'], $_SESSION['key']),
array(i5_lib=>$_SESSION['lib']));
if (!$conn) { echo 'bad';
die(i5_errormsg());
}
$query = "delete from tmpdesc where deprcl = '$parcel'";
$stmt = db2_exec($conn, $query);
for ($a = 0; $a <= $b; $a++) {
$query = "insert into tmpdesc (deprcl, derecn, dedesc) values('$parcel',
$a+1, '$line[$a]')";
$prepared_query = db2_prepare($conn, $query);
$stmt = db2_exec($conn, $prepared_query);
if (!$stmt) {
echo 'Error during query insertion<br/>Code: ' . i5_errno($conn)
. '<br/>';
echo 'Message: ' . i5_errormsg($conn) . '<br/>';
}
}
echo '<p><br/>Legal descriptions have been sent.</p>';
return '0';
} else {
echo '<font color=red>You have ', $b, ' lines of descriptions which is
more than the 999 allowed.</font>';
return '1';
}
因此,如果用户在文本区域中输入 Andersons Farm,那么即使使用准备好的语句,DB2 文件中的最终结果也是 Andersons Farm。
解决方案
推荐阅读
- api - 如何从 DBpedia 获取具有高度的所有人员实例?
- azure - 是否可以在一个租户中注册 Azure 应用程序,而在另一个租户中注册应用程序服务
- regex - 正则表达式捕获该字符串包含字母数字、下划线和空格,但以字母开头
- visual-studio-code - VSCode jsconfig.json 错误“node_modules/agent-base/dist/src/index”未找到
- sql - 不同的 SQL 组字符串
- sql - PostgreSQL 无法将现有列设置为 IDENTITY
- python - 欧几里德的除法算法(找到 HCF )有没有更好的方法?
- java - 如何取消选择 recyclerView 项目 onSwiped?
- php - 单击提交按钮时,php 不起作用,显示代码,但不发送电子邮件
- virtualenv - 如何让 Gunicorn 成为 Ubuntu 18.04 上的守护进程?