Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde, amigos!!!
Preciso fazer um Banco onde eu possa registrar aquela sequência de números dos Boletos Bancários, por exemplo para Boletos de conta de Água preciso fazer 4 caixas com 12 dígitos cada uma, até aí tudo bem eu faço, só que descobri que há um limite de número no PHPMyAdmin, que é 2147483647, todo numeral maior que este que for inserido no banco ele acaba gravando o número 2147483647, por exemplo se o código de barras tiver o número 000000000000 até 999999999999, não vai ter como registrá-lo, pois sempre vai aparecer o resultado como 2147483647.
Já pesquisei no Google a respeito, e descobri que algumas pessoas mudaram o tipo de Int para Varchar ou Bigint e conseguiram resolver este problema, mas eu tentei fazer isso e não aconteceu nada, continuou do mesmo jeito dando o mesmo resultado.
Será que alguém pode me ajudar a resolver este problema?
Aqui vai o arquivo que estou fazendo através do Dreamweaver, talvez possa exitir algo errado nele que possa estar dando este erro.
<?php require_once('Connections/ConexaoBoletoNovo.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;
}
}
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="Erro_no_formulario.php";
$loginUsername = $_POST['codigo_consumidor'];
$LoginRS__query = sprintf("SELECT codigo_consumidor FROM agua_dados WHERE codigo_consumidor=%s", GetSQLValueString($loginUsername, "text"));
mysql_select_db($database_ConexaoBoletoNovo, $ConexaoBoletoNovo);
$LoginRS=mysql_query($LoginRS__query, $ConexaoBoletoNovo) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}
$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 agua_dados (nome_consumidor, codigo_consumidor, numero1_controle, numero2_controle, numero3_controle, numero4_controle, vencimeto, valor) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['consumidor'], "text"),
GetSQLValueString($_POST['codigo_consumidor'], "text"),
GetSQLValueString($_POST['codigo_1'], "int"),
GetSQLValueString($_POST['codigo_2'], "int"),
GetSQLValueString($_POST['codigo_3'], "int"),
GetSQLValueString($_POST['codigo_4'], "int"),
GetSQLValueString($_POST['Vencimento'], "text"),
GetSQLValueString($_POST['valor'], "text"));
mysql_select_db($database_ConexaoBoletoNovo, $ConexaoBoletoNovo);
$Result1 = mysql_query($insertSQL, $ConexaoBoletoNovo) or die(mysql_error());
}
?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script>
function insere1(){
if(document.form1.codigo_1.value.length==11){</script>
<script>
function insere2(){
if(document.form1.codigo_2.value.length==11){</script>
<script>
function insere3(){
if(document.form1.codigo_3.value.length==11){</script>
<script>
function insere4(){
if(document.form1.codigo_4.value.length==11){</script>
<script>
function insere5(){
if(document.form1.Vencimento.value.length==2){</script>
<script>
function insere6(){
if(document.form1.Vencimento.value.length==5){</script>
<script>
function insere7(){
if(document.form1.Vencimento.value.length==9){</script>
<body>
<table width="100%" border="0">
<tr>
<th scope="col"> </th>
<th scope="col">Pagamento de Conta de Água</th>
<th scope="col"> </th>
</tr>
<tr>
<td> </td>
<td><form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="100%" border="0">
<tr>
<td >Nome do Consumidor</td>
<td colspan="4" ><label>
<input type="text" name="consumidor" id="textfield" />
</label></td>
</tr>
<tr>
<td>Código do consumidor</td>
<td colspan="4"><label>
<input type="text" name="codigo_consumidor" />
</label></td>
</tr>
<tr>
<td>Código de barras</td>
<td><label><input type="text" onkeypress="insere1();" name="codigo_1" value="" size="14" /></label></td>
<td><label><input type="text" onkeypress="insere2();" name="codigo_2" value="" size="14" /></label></td>
<td><label><input type="text" onkeypress="insere3();" name="codigo_3" value="" size="11" /></label></td>
<td><label><input type="text" onkeypress="insere4();" name="codigo_4" value="" size="11" /></label></td>
</tr>
<tr>
<td>Vencimento</td>
<td colspan="4"><label>
<input type="text" onkeypress="insere5(),insere6(),insere7();" name="Vencimento" value="" size="32" />
</label></td>
</tr>
<tr>
<td>Valor</td>
<td colspan="4"><label>
<input type="text" name="valor" />
</label></td>
</tr>
<tr>
<td> </td>
<td colspan="4"><label>
<input type="submit" value="Enviar" />
</label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
Obrigado.
Carregando comentários...