Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
estou com o mesmo probelma deste post:
http://forum.imasters.com.br/index.php?showtopic=201711
So que não consigo enteder, ele diz que o problema esta aqui:
<input type="hidden" name="not_usuario_id" value="<?php echo $row_rsUsuarioLogado['usu_id']; ?>">
ta o problema esta ai, mas o que fazer para consertar?
noticia_inserir.php
<?php require_once('Connections/ConnImasters.php'); ?><?phpfunction GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 noticias (not_titulo, not_conteudo, not_data, not_status, not_fonte, not_usuario_id) VALUES (%s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['not_titulo'], "text"), GetSQLValueString($_POST['not_conteudo'], "text"), GetSQLValueString($_POST['not_data'], "date"), GetSQLValueString($_POST['not_status'], "text"), GetSQLValueString($_POST['not_fonte'], "text"), GetSQLValueString($_POST['not_usuario_id'], "text")); mysql_select_db($database_ConnImasters, $ConnImasters); $Result1 = mysql_query($insertSQL, $ConnImasters) or die(mysql_error()); $insertGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}$colname_rsUsuarioLogado = "-1";if (isset($_GET['MM_Username'])) { $colname_rsUsuarioLogado = (get_magic_quotes_gpc()) ? $_GET['MM_Username'] : addslashes($_GET['MM_Username']);}mysql_select_db($database_ConnImasters, $ConnImasters);$query_rsUsuarioLogado = sprintf("SELECT * FROM usuarios WHERE usu_email = '%s'", $colname_rsUsuarioLogado);$rsUsuarioLogado = mysql_query($query_rsUsuarioLogado, $ConnImasters) or die(mysql_error());$row_rsUsuarioLogado = mysql_fetch_assoc($rsUsuarioLogado);$totalRows_rsUsuarioLogado = mysql_num_rows($rsUsuarioLogado);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Not_titulo:</td> <td><input type="text" name="not_titulo" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right" valign="top">Not_conteudo:</td> <td><textarea name="not_conteudo" cols="50" rows="5"></textarea> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Not_data:</td> <td><input type="text" name="not_data" value="<?php echo date('y/m/d'); ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Not_status:</td> <td><select name="not_status"> <option value="ON" <?php if (!(strcmp("ON", ""))) {echo "SELECTED";} ?>>visivel</option> <option value="OFF" <?php if (!(strcmp("OFF", ""))) {echo "SELECTED";} ?>>oculto</option> </select> </td> </tr> <tr valign="baseline"> <td nowrap align="right">Not_fonte:</td> <td><input type="text" name="not_fonte" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insert record"></td> </tr> </table> <input type="hidden" name="not_usuario_id" value="<?php echo $row_rsUsuarioLogado['usu_id']; ?>"> <input type="hidden" name="MM_insert" value="form1"></form><p> </p></body></html><?phpmysql_free_result($rsUsuarioLogado);?>Index.php (aonde parece o registro da inserção )
<?php require_once('Connections/ConnImasters.php'); ?><?php//initialize the sessionif (!isset($_SESSION)) { session_start();}// ** Logout the current user. **$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; }}?><?phpif (!isset($_SESSION)) { }$MM_authorizedUsers = "";$MM_donotCheckaccess = "true";// *** Restrict Access To Page: Grant or deny access to this pagefunction isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; }$MM_restrictGoTo = "login.php";if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit;}?><?phpmysql_select_db($database_ConnImasters, $ConnImasters);$query_rsRelatorioNoticias = "SELECT * FROM noticias INNER JOIN usuarios ON noticias.not_usuario_id = usuarios.usu_id ORDER BY not_id DESC";$rsRelatorioNoticias = mysql_query($query_rsRelatorioNoticias, $ConnImasters) or die(mysql_error());$row_rsRelatorioNoticias = mysql_fetch_assoc($rsRelatorioNoticias);$totalRows_rsRelatorioNoticias = mysql_num_rows($rsRelatorioNoticias);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><style type="text/css"><!--.style1 {color: #000000}--></style></head><body><p>Index</p><p><a href="noticia_inserir.php">Inserir </a><a href="cadastro_usuario.php">cadastro</a> <a href="<?php echo $logoutAction ?>">Log out</a></p><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <th width="22%" height="20" scope="col">Titulo</th> <th width="23%" scope="col">Data</th> <th width="24%" scope="col">Estatus</th> <th width="21%" scope="col">Responsável</th> <th colspan="2" scope="col">Funções</th> </tr> <tr> <?php do { ?> <td bgcolor="#FF9900"><span class="style1"><?php echo $row_rsRelatorioNoticias['not_titulo']; ?></span></td> <td bgcolor="#FF9900"><span class="style1"><?php echo $row_rsRelatorioNoticias['not_data']; ?></span></td> <td bgcolor="#FF9900"><span class="style1"><?php echo $row_rsRelatorioNoticias['not_status']; ?></span></td> <td bgcolor="#FF9900"><span class="style1"><?php echo $row_rsRelatorioNoticias['usu_nome']; ?></span></td> <td width="5%" bgcolor="#FFFFFF"><div align="center" class="style1"><img src="btns/editar.png" width="20" height="20" /></div></td> <td width="5%" bgcolor="#FFFFFF"><div align="center" class="style1"><img src="btns/apagar.png" width="20" height="20" /></div></td> <?php } while ($row_rsRelatorioNoticias = mysql_fetch_assoc($rsRelatorioNoticias)); ?></tr></table><p> </p></body></html><?phpmysql_free_result($rsRelatorioNoticias);?>Isso não é um problema, o que está acontecendo é que no banco o campo 'not_usuario_id' está definido como NOT NULL, e portanto, não pode ser nulo. Pelo nome do campo, imagino que seja a chave primária da tabela.
por favor pessoal me ajudem!