Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

rpan

o que ha de errado aqui ?

Recommended Posts

Pessoal,Não estou conseguindo bloquear os registros se o numero de registros for maior que o indicado. O codigo abaixo errado ?Obrigado a todosecho $totalRows_contador;$max=136;if ($totalRows_contador >= $max) { echo ' -->Bloqueado';} else {mysql_select_db($database_estudo, $estudo);$query_cadastra = "SELECT * FROM anuncio";$cadastra = mysql_query($query_cadastra, $estudo) or die(mysql_error());$row_cadastra = mysql_fetch_assoc($cadastra);$totalRows_cadastra = mysql_num_rows($cadastra);}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Posta como ele está retornando a variável $totalRows_contadorCertamente o erro está ai, ou entao o numero de registros é menor que 136. Tente fazer um testecom um número menor.FaloU!

Ola Vinicius,Testei agora e esta em 143. Ja fiz varias simulações e não da certo.Eu to penando pra fazer isso funcionar. Utilizo o metodo de inserção de formulario do dreamweaver c/o php.Alguma dica adicional ?Vou postar o codigo cru pra ver se esta correto e se pode me ajudar aonde devo colocar a comparação.Obrigado novamente<?php require_once('Connections/estudo.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 anuncio (id, id_cliente, anuncio) VALUES (%s, %s, %s)", GetSQLValueString($_POST['id'], "int"), GetSQLValueString($_POST['id_cliente'], "int"), GetSQLValueString($_POST['anuncio'], "text")); mysql_select_db($database_estudo, $estudo); $Result1 = mysql_query($insertSQL, $estudo) or die(mysql_error());}mysql_select_db($database_estudo, $estudo);$query_cadastra = "SELECT * FROM anuncio";$cadastra = mysql_query($query_cadastra, $estudo) or die(mysql_error());$row_cadastra = mysql_fetch_assoc($cadastra);$totalRows_cadastra = mysql_num_rows($cadastra);mysql_select_db($database_estudo, $estudo);$query_contador = "SELECT * FROM anuncio WHERE id_cliente = 1";$contador = mysql_query($query_contador, $estudo) or die(mysql_error());$row_contador = mysql_fetch_assoc($contador);$totalRows_contador = mysql_num_rows($contador);?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><br><br><br><br><table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td><form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Id:</td> <td><input type="text" name="id" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Id_cliente:</td> <td><input type="text" name="id_cliente" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Anuncio:</td> <td><input type="text" name="anuncio" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input name="submit" type="submit" value="Insert record"></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form></td> </tr></table><p> </p><p> </p></body></html><?phpmysql_free_result($cadastra);mysql_free_result($contador);?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.