dqwh0109 2011-08-09 02:24
浏览 41

继续得到未定义的索引错误,无法弄清楚如何在子模式窗口中声明值

I am a beginner in PHP and MYSQL, I really need your help. I am attempting to insert new information into the database, and installed the submodal feature to input and view customer notes. I am attempting to Insert a "New Customer" into the database, and keep getting undefined index error for the "Notes" field...I am not sure how to declare the value since I am using the submodal feature and also have an Image that the user will click on to activate the submodal. Here is the code for the table...thank you all very much!!

 <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" target="_top" id="form1">
<table width="30%%" border="1">
<tr>
  <td>First Name:</td>
  <td><label for="First_Name"></label>
  <input type="text" name="First_Name" id="First_Name" /></td>
</tr>
<tr>
  <td>Last Name:</td>
  <td><label for="Last_Name"></label>
  <input type="text" name="Last_Name" id="Last_Name" /></td>
</tr>
<tr>
  <td>Address:</td>
  <td><label for="Address"></label>
  <input type="text" name="Address" id="Address" /></td>
</tr>
<tr>
  <td>City:</td>
  <td><label for="City"></label>
  <input type="text" name="City" id="City" /></td>
</tr>

<tr>
  <td>Zip:</td>
  <td><label for="Zip"></label>
  <input type="text" name="Zip" id="Zip" /></td>
</tr>
<tr>
  <td>Phone:</td>
  <td><label for="Phone"></label>
  <input type="text" name="Phone" id="Phone" /></td>
</tr>
<tr>
  <td>E-Mail:</td>
  <td><label for="Email"></label>
  <input type="text" name="Email" id="Email" /></td>
</tr>
<tr>
  <td>Fee:</td>
  <td><label for="Fee"></label>
  <input type="text" name="Fee" id="Fee" /></td>
</tr>
<tr>
  <td>Referral Source:</td>
  <td><label for="Referral_Source"></label>
  <input type="text" name="Referral_Source" id="Referral_Source" /></td>
</tr>
<tr>
  <td>Notes:</td>
  <td><a href="subform.php?Id=<?php echo $row_Recordset1['Id']; ?>" class="submodal"><img     
  src="Images/editnote.png" class="pencil" width="33" height="33" /></a></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td><input type="submit" name="Submit" id="Submit" value="Submit" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />

 Notice: Undefined index: Notes in /home/content/02/8116402/html/testleadform.php on line 55

                        GetSQLValueString($_POST['Notes'], "text"));


 Notice: Undefined index: Notes in /home/content/02/8116402/html/testleadform.php on line 55

Warning: Cannot modify header information - headers already sent by (output started at    
/home/content/02/8116402/html/testleadform.php:55) in /home/content/02/8116402/html/testleadform.php       
on  line 65

Line 65: header(sprintf("Location: %s", $insertGoTo));




<?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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO Leads (First_Name, Last_Name, Address, City, `State`, Zip, Phone,   
Email, Fee, Referral_Source, Notes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                   GetSQLValueString($_POST['First_Name'], "text"),
                   GetSQLValueString($_POST['Last_Name'], "text"),
                   GetSQLValueString($_POST['Address'], "text"),
                   GetSQLValueString($_POST['City'], "text"),
                   GetSQLValueString($_POST['State'], "text"),
                   GetSQLValueString($_POST['Zip'], "text"),
                   GetSQLValueString($_POST['Phone'], "text"),
                   GetSQLValueString($_POST['Email'], "text"),
                   GetSQLValueString($_POST['Fee'], "int"),
                   GetSQLValueString($_POST['Referral_Source'], "text"),
                   GetSQLValueString($_POST['Notes'], "text"));

mysql_select_db($database_cms, $cms);
$Result1 = mysql_query($insertSQL, $cms) or die(mysql_error());

$insertGoTo = "leads.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
 header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_cms, $cms);
$query_Recordset1 = "SELECT * FROM Leads";
$Recordset1 = mysql_query($query_Recordset1, $cms) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
  • 写回答

2条回答 默认 最新

  • drgweamoi473182981 2011-08-09 02:26
    关注

    Did you access this page through a form? If not, $_POST does not exist. Also if there is not a field known as Notes (case sensitive - i.e. <input name="Notes">), then this field is non-existent and will throw this type of error. If it is returning to this page, check that $_POST exists with if(isset($_POST)) before trying to access the variable.

    ORIGINAL ANSWER

    If you are getting an undefined index error in your Notes: section, then $row_Recordset1['Id']; does not exist. Make sure that your database field is Id (case sensitive) and not ID, id, or some variation. class="submodal" looks like HTML code and should not effect this issue.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向