v1ru5 Posted October 12, 2011 Report Share Posted October 12, 2011 <?php require_once('../Connections/banner_random.php'); ?><?phpif (!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;}}$colname_RsAtualizar = "-1";if (isset($_GET['ctg'])) { $colname_RsAtualizar = $_GET['ctg'];}mysql_select_db($database_banner_random, $banner_random);$query_RsAtualizar = sprintf("SELECT * FROM ban_categorias WHERE ctg_id = %s", GetSQLValueString($colname_RsAtualizar, "int"));$RsAtualizar = mysql_query($query_RsAtualizar, $banner_random) or die(mysql_error());$row_RsAtualizar = mysql_fetch_assoc($RsAtualizar);$totalRows_RsAtualizar = mysql_num_rows($RsAtualizar);if (isset($_POST['cadastrar'])) { $titulo = $_POST['titulo']; $status = $_POST['status'];mysql_select_db($database_banner_random, $banner_random);$query_RsCadastrar = "INSERT INTO ban_categorias (ctg_titulo, ctg_status) VALUES ('$titulo' ,'$status') "; $RsCadastrar = mysql_query($query_RsCadastrar, $banner_random) or die(mysql_error());header("Location: categorias.php?procedimento=cadastro");}if (isset($_POST['atualizar'])) { $titulo = $_POST['titulo']; $status = $_POST['status']; $catid = $_POST['ctg_id']; mysql_select_db($database_banner_random, $banner_random);$query_RsCadastrar = "UPDATE ban_categorias SET ctg_titulo=$titulo',ctg_status='$status' WHERE ctg_id=$catid";$RsCadastrar = mysql_query($query_RsCadastrar, $banner_random) or die(mysql_error());header("Location: categorias.php?procedimento=atualizacao");"UPDATE ban_categorias ctg_titulo='$titulo',ctg_status='$status' WHERE ctg_id=$catid";}if (isset($_GET['apagar])) { $catid = $_GET['ctg']; mysql_select_db($database_banner_random, $banner_random);$query_RsCadastrar = "DELETE FROM ban_categorias WHERE ctg_id=$catid";$RsCadastrar = mysql_query($query_RsCadastrar, $banner_random) or die(mysql_error());header("Location: categorias.php?procedimento=apagar");}?><!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" /><title>Formulário de Categorias</title><link href="../css/css.css" rel="stylesheet" type="text/css" /></head><body><div class="pagina"><div class="topo">Formulário de Categorias</div><div class="centro"> <form id="form1" name="form1" method="post" action=""> <table width="0" border="0" class="tablelist"> <tr> <th>Titulo:</th> <td><label> <input name="titulo" type="text" id="titulo" value="<?php echo $row_RsAtualizar['ctg_titulo]; ?>" size="40" maxlength="100" /> </label></td> </tr> <tr> <th>Status:</th> <td><label> <select name="status" id="status"> <option value="1" <?php if (!(strcmp(1, $row_RsAtualizar['ctg_status']))) {echo "selected=\"selected\"";} ?>>Ativo</option> <option value=0" <?php if (!(strcmp(0, $row_RsAtualizar['ctg_status]))) {echo "selected=\"selected\"";} ?>>Inativo</option> </select> </label></td> </tr> <tr> <td><input name="ctg_id" type="hidden" id="ctg_id" value="<?php echo $row_RsAtualizar['ctg_id']; ?>" /></td> <td><label> <?php if($_GET['ctg] == NULL) {?> <input type="submit" name="cadastrar" id="cadastrar" value="cadastrar" /> <?php } else { ?> <input type="submit" name="atualizar" id="atualizar" value="atualizar" /> <?php } ?> </label></td> </tr> </table> </form></div><div class="rodape">HDweb.com.br</div></body></html>http://imageshack.us/photo/my-images/263/errox.gif Quote Link to comment Share on other sites More sharing options...
0 ESerra Posted October 12, 2011 Report Share Posted October 12, 2011 Troca aquilo ali por:<?php if(!isset($_GET['ctg'])) {?> Quote Link to comment Share on other sites More sharing options...
0 v1ru5 Posted October 13, 2011 Author Report Share Posted October 13, 2011 obrigado amigo vou tentar valeu :rolleyes: Quote Link to comment Share on other sites More sharing options...
0 v1ru5 Posted October 14, 2011 Author Report Share Posted October 14, 2011 Troca aquilo ali por:<?php if(!isset($_GET['ctg'])) {?> Ola amigo fis a troca como você avia sugerido mas não funcionouEu tenho uma pagina em localhost de cadastro e atualização, ambos esta com os dois botões na mesma páginaquando solicita o cadastro ai só aparece o botão de cadastro e se é atualização só atualização, mas na página de cadastro da o erro o código abaixo é referente ao errooque eu poderia fazer para tirar este erro?<td><input name=ctg_id" type="hidden" id="ctg_id" value="<?php echo $row_RsAtualizar['ctg_id]; ?>" /></td><td><label><?php if($_GET['ctg'] == NULL) {?><input type="submit" name="cadastrar" id="cadastrar" value="cadastrar" /><?php } else { ?><input type="submit" name="atualizar" id="atualizar" value="atualizar" /><?php } ?>segue o link da imagem do erro http://imageshack.us/photo/my-images/263/errox.gif Quote Link to comment Share on other sites More sharing options...
0 ESerra Posted October 14, 2011 Report Share Posted October 14, 2011 Você troucou isto:<?php if($_GET['ctg'] == NULL) {?>Por isto:<?php if(!isset($_GET['ctg'])) {?> E continuou o mesmo erro? Estranho... era para funcionar. Desativa os notices então. Quote Link to comment Share on other sites More sharing options...
0 v1ru5 Posted October 14, 2011 Author Report Share Posted October 14, 2011 Você troucou isto:<?php if($_GET['ctg'] == NULL) {?>Por isto:<?php if(!isset($_GET['ctg'])) {?> E continuou o mesmo erro? Estranho... era para funcionar. Desativa os notices então.Amigo onde eu devo desativa ?você poderia identificar no código a cima para eu não erra! Quote Link to comment Share on other sites More sharing options...
Question
v1ru5
<?php require_once('../Connections/banner_random.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;
}
}
$colname_RsAtualizar = "-1";
if (isset($_GET['ctg'])) {
$colname_RsAtualizar = $_GET['ctg'];
}
mysql_select_db($database_banner_random, $banner_random);
$query_RsAtualizar = sprintf("SELECT * FROM ban_categorias WHERE ctg_id = %s", GetSQLValueString($colname_RsAtualizar, "int"));
$RsAtualizar = mysql_query($query_RsAtualizar, $banner_random) or die(mysql_error());
$row_RsAtualizar = mysql_fetch_assoc($RsAtualizar);
$totalRows_RsAtualizar = mysql_num_rows($RsAtualizar);
if (isset($_POST['cadastrar'])) {
$titulo = $_POST['titulo'];
$status = $_POST['status'];
mysql_select_db($database_banner_random, $banner_random);
$query_RsCadastrar = "INSERT INTO ban_categorias (ctg_titulo, ctg_status) VALUES ('$titulo' ,'$status') ";
$RsCadastrar = mysql_query($query_RsCadastrar, $banner_random) or die(mysql_error());
header("Location: categorias.php?procedimento=cadastro");
}
if (isset($_POST['atualizar'])) {
$titulo = $_POST['titulo'];
$status = $_POST['status'];
$catid = $_POST['ctg_id'];
mysql_select_db($database_banner_random, $banner_random);
$query_RsCadastrar = "UPDATE ban_categorias SET ctg_titulo=$titulo',ctg_status='$status' WHERE ctg_id=$catid";
$RsCadastrar = mysql_query($query_RsCadastrar, $banner_random) or die(mysql_error());
header("Location: categorias.php?procedimento=atualizacao");
"UPDATE ban_categorias ctg_titulo='$titulo',ctg_status='$status' WHERE ctg_id=$catid";
}
if (isset($_GET['apagar])) {
$catid = $_GET['ctg'];
mysql_select_db($database_banner_random, $banner_random);
$query_RsCadastrar = "DELETE FROM ban_categorias WHERE ctg_id=$catid";
$RsCadastrar = mysql_query($query_RsCadastrar, $banner_random) or die(mysql_error());
header("Location: categorias.php?procedimento=apagar");
}
?>
<!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" />
<title>Formulário de Categorias</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="pagina">
<div class="topo">Formulário de Categorias</div>
<div class="centro">
<form id="form1" name="form1" method="post" action="">
<table width="0" border="0" class="tablelist">
<tr>
<th>Titulo:</th>
<td><label>
<input name="titulo" type="text" id="titulo" value="<?php echo $row_RsAtualizar['ctg_titulo]; ?>" size="40" maxlength="100" />
</label></td>
</tr>
<tr>
<th>Status:</th>
<td><label>
<select name="status" id="status">
<option value="1" <?php if (!(strcmp(1, $row_RsAtualizar['ctg_status']))) {echo "selected=\"selected\"";} ?>>Ativo</option>
<option value=0" <?php if (!(strcmp(0, $row_RsAtualizar['ctg_status]))) {echo "selected=\"selected\"";} ?>>Inativo</option>
</select>
</label></td>
</tr>
<tr>
<td><input name="ctg_id" type="hidden" id="ctg_id" value="<?php echo $row_RsAtualizar['ctg_id']; ?>" /></td>
<td><label>
<?php if($_GET['ctg] == NULL) {?>
<input type="submit" name="cadastrar" id="cadastrar" value="cadastrar" />
<?php } else { ?>
<input type="submit" name="atualizar" id="atualizar" value="atualizar" />
<?php } ?>
</label></td>
</tr>
</table>
</form>
</div>
<div class="rodape">HDweb.com.br</div>
</body>
</html>
http://imageshack.us/photo/my-images/263/errox.gif
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.