www.webdeveloper.com
Results 1 to 2 of 2

Thread: Weird Number inserted into the MySQL

  1. #1
    Join Date
    Apr 2010
    Posts
    3

    Unhappy Weird Number inserted into the MySQL

    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 
    "";
      }

    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;

    This is how I use the function:

    //nuEmpresa contains 12275
    auxACUSE := revisarDuplicidad(nuEmpresa)
    IF auxACUSE is not empty string THEN
    DO encuestaCompletada(auxACUSE)

    This is the very simple table

    Code:
    CREATE TABLE `acuseemoe` (
      `ACUSE` int(15) NOT NULL,
      `MES` int(2) NOT NULL,
      `ANHO` int(2) NOT NULL,
      PRIMARY KEY  (`ACUSE`)
    )
    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.

    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.

  2. #2
    Join Date
    Apr 2010
    Posts
    3
    Got it... INT is too small.. BIGIT fix it...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles