[Resolvido] PHP MYSQL - erro
Toda vez que faço uma busca usando o código abaixo é acrescentada uma linha no banco de dados (MYSQLQ) - alguém pode me dizer se o problema é no código abaixo?
<?php require_once('minhaConexao'); ?>
<?php
function 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"] == "form-insere")) {
//insere a foto:
if($foto){
move_uploaded_file($foto, "../imagens/fotos_novos/" . $foto_name);
}else{
$foto_name = "";
}
$insertSQL = sprintf("INSERT INTO novos (categoria) VALUES (%s)",
GetSQLValueString($_GET['categoria'], "text"));
mysql_select_db($minha conexao);
$Result1 = mysql_query($insertSQL, $$minha conexa) or die(mysql_error());
$insertGoTo = "ah_novos.php?categoriaz=$categoria";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
mysql_select_db($minha conexa);
$query_cat = "SELECT DISTINCT categoria FROM novos ORDER BY categoria ASC";
$cat = mysql_query($query_cat, $minha conexa) or die(mysql_error());
$row_cat = mysql_fetch_assoc($cat);
$totalRows_cat = mysql_num_rows($cat);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Categorias</title>
<link href="css/site.css" rel="stylesheet" type="text/css">
<STYLE TYPE='text/css'><!-- TextRollover-1 -->
a:link { color:#000000; text-decoration:none}
a:visited { color:#000000; text-decoration:none}
a:hover { color:#FF0000; text-decoration:none; cursor:hand}
a:active { color:#000000; text-decoration:none}
</STYLE>
<link href="meuEstilo.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="82%">
<!--Inicio Tabela de consulta-->
<form action="ah_novos_busca.php" method="POST" name="escolha" id="form-data">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#FFFFCC" class="txt-menor">
<td width="41%" rowspan="2" valign="middle" bgcolor="#FFFFFF"><img src="imagens_novas/bola.jpg" width="16" height="15"> <span class="fonteTituloEquipamentos">Equipamentos Novos</span></td>
<td width="37%" bgcolor="#FFFFFF" class="fonteDescricaoEquipamentos"><div align="left">Se preferir escolha uma categoria abaixo.</div></td>
<td width="22%" rowspan="2" valign="bottom" bgcolor="#FFFFFF">
<input type=submit value="Buscar"></td>
</tr>
<tr bgcolor="#FFFFCC" class="txt-menor">
<td bgcolor="#FFFFFF"><select name="escolha" class="form">
<!--fim Tabela de consulta-->
<?php
do {
?>
<option value="<?php echo $row_cat['categoria']?>"<?php if (!(strcmp($row_cat['categoria'], $categoriay))) {echo "SELECTED";} ?>> <?php echo $row_cat['categoria']?></option>
<?php
} while ($row_cat = mysql_fetch_assoc($cat));
$rows = mysql_num_rows($cat);
if($rows > 0) {
mysql_data_seek($cat, 0);
$row_cat = mysql_fetch_assoc($cat);
}
?>
</select></td>
</tr></table>
<p>
<input type="hidden" name="MM_insert" value="form-insere">
</p>
</form></td></tr><tr><td> </td></tr></table></td></tr></table>
</body>
</html>
<?php
mysql_free_result($cat);
?>Discussão (1)
Carregando comentários...