Hi guys...
I am experiencing a very strange error.
I am generating a Unique number regarding the actual month and date and a extra number, something like this.
12275 04 10
<CompanyNumber><Month><Year>
Therefore I got this 12275.
This is the PHP script
PHP Code:function revisarDuplicidad($nuEmpresa)
{
mysql_connect("localhost", "root", "admin") or die("Could not connect: " . mysql_error());
mysql_select_db("mmic");
$mes = date("m");
$anho = date("y");
$ACUSE = $nuEmpresa . $mes . $anho;
$query = 'SELECT ACUSE FROM acuseEMOE WHERE ACUSE="' . $ACUSE . '"';
//echo '<br />query: ' . $query;
$result=mysql_query($query);
if ($result)
{
$dato = mysql_fetch_row($result);
if($dato[0] != "")
return "";
else
return $ACUSE;
}
else
{
echo '<br />Error, ' . mysql_error() . "\n";
return "";
}
}
This is how I use the function:PHP Code:function encuestaCompletada($ACUSE)
{
mysql_connect("localhost", "root", "admin") or die("Could not connect: " . mysql_error());
mysql_select_db("mmic");
$mes = date("m");
$anho = date("y");
$query = "INSERT INTO acuseEMOE VALUES(" . $ACUSE . ", " . $mes . ", " . $anho . ")";
echo '<br />query: ' . $query;
mysql_query($query);
return $ACUSE;
}
//nuEmpresa contains 12275
auxACUSE := revisarDuplicidad(nuEmpresa)
IF auxACUSE is not empty string THEN
DO encuestaCompletada(auxACUSE)
This is the very simple table
In fact!!! with 12275 I got the right values in the DB, but not with 340660 nor 9985922. I don't know what happend and I am affraid that this will keep happening with more values.Code:CREATE TABLE `acuseemoe` ( `ACUSE` int(15) NOT NULL, `MES` int(2) NOT NULL, `ANHO` int(2) NOT NULL, PRIMARY KEY (`ACUSE`) )
I got this values inserted in the DB:
340660 --> ACUSE = 2147483647 and not 3406600410
I just uncomment the echo line to see the inserted query and it shows the right sintaxis INSERT INTO acuseEMOE VALUES(3406600410, 04, 10), but it's hasn't been saved like that.
Same for 9985922, INSERT INTO acuseEMOE VALUES(99859220410, 04, 10) and I got on the database 2147483647 instead of 99859220410 for some reason same as 340660.
What do you think it could be.
Why it works with 122750410 and not with 340660 nor 9985922.
Thank you in advance guys.


Reply With Quote
Bookmarks