在张贴“笔记”时遇到了很多麻烦.字段添加到数据库中,同时使用子模态特性
Having a lot of trouble posting my "Notes" field into the database while using the submodal feature
我在从次模态特性中保存Notes部分时遇到了很多麻烦。其他所有东西都可以保存,但笔记不会。我做错了什么?
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
?>
<?php require_once('Connections/cms.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) :
mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "lead_note")) {
$updateSQL = sprintf ("UPDATE Leads SET Notes = CONCAT_WS(''n', Notes, ''n', %s) WHERE Id=%d",
GetSQLValueString($_POST['Notes'], "text"),
GetSQLValueString($_POST['Id'], "int"));
mysql_select_db($database_cms, $cms);
$Result1 = mysql_query($updateSQL, $cms) or die(mysql_error());
$updateGoTo = "testleadform.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Recordset1 = "-1";
if (isset($_GET['Id'])) {
$colname_Recordset1 = $_GET['Id'];
}
mysql_select_db($database_cms, $cms);
$query_Recordset1 = sprintf("SELECT Id, First_Name, Last_Name, Notes FROM Leads WHERE Id = %s",
GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $cms) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript" src="jquery.js" type="text/javascript"></script>
<script>
function clickSubmit() {
//$("form").submit();
// window.opener.document.form1.Notes.value = $('#Notes').text();
window.parent.hidePopWin();
}
</script>
</head>
<body>
<table><tr><td>
<div id="lead_box">
<form action="<?php echo $editFormAction; ?>" method="POST" name="lead_note" id="lead_note"
target="_top">
<input type="hidden" name="Id" id="Id" value="<?php echo $row_Recordset1['Id']; ?>" />
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<tr>
<td colspan="2" bgcolor="#eeeeee"><p align="center" class="name"></p></td>
</tr>
<tr>
<td><textarea rows="15" style="width: 99%" readonly><?php echo $row_Recordset1['Notes']; ?></textarea>
</td>
</tr>
<tr>
<td valign="top"><p class="title">Add Note:</p></td>
<tr>
<td>
<textarea name="Notes" id="Notes" style="width: 99%" rows="5"></textarea>
</td>
</tr>
</table>
<input type="hidden" name="MM_update" value="lead_note" />
</form>
</div><!-- and of lead box -->
</td></tr>
<tr><td>
<div align="right">
<input type="submit" name="save" id="save" value="Save" onClick="clickSubmit()"/>
<input type="button" name="cancel" id="cancel" value="Cancel" onClick="window.parent.hidePopWin()"/>
</div>
</td></tr></table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
为什么不使用PDO或MYSQLI代替mysql?如果你使用PDO,你不需要自己"清除"变量:
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
....
}
可以使用PDO预处理语句:pdostatement
请在这里插入var_dump
var_dump($_POST);
$updateSQL = sprintf ("UPDATE Leads SET Notes = CONCAT_WS(''n', Notes, ''n', %s) WHERE Id=%d",
GetSQLValueString($_POST['Notes'], "text"),
GetSQLValueString($_POST['Id'], "int"));
var_dump( $updateSQL,$_POST['Notes']);
并告诉我们,输出结果是什么
相关文章:
- 我想使用模态通过php文件发送邮件,并且我希望在提交关闭后关闭pop
- 打开一个模态并将其链接到AngularJS中的指令
- SemanticUI模态not onDeny/onApprove事件未激发
- 有没有比在app.js上绑定模块名称更好的方法来动态加载视图模型和视图以显示模态
- 如何通过所选索引(AngularJS)在模态弹出窗口中显示数据
- 包含数据库中相关信息的开放模态
- bootstrap消除模态并显示另一个模态
- 模态提示-如何重写此代码
- 模态框无法正常工作
- 将数据传递给由服务创建的Ionic模态
- iframe模态无法关闭
- 点击AngularJS模态窗口捕捉背景事件
- (Laravel)使用数据库中的数据动态打开模态
- 当数据库中已经存在 fname 时,我想弹出一个模态
- JQuery UI模态表单对话框保存数据到数据库
- 从数据库中引导模态动态数据
- 如何显示HTML模态,取决于Javascript/AJAX数据库调用的结果
- 显示从mysql数据库检索的模态字段中的数据
- 在张贴“笔记”时遇到了很多麻烦.字段添加到数据库中,同时使用子模态特性
- While循环只显示数据库中的最后一行,当点击按钮[显示模态对话框]