SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ERROR: Incorrect integer value PHP -MySQL

    Hello, I keep getting this error when I try to insert a record into a mysql table through php:

    ERROR: Incorrect integer value for: "column mar_id" at row 1

    There seems to be nothing wrong since the column is declared as int and the value is passed through a select box as a numeric value.

    I have no problem when I insert it directly from phpMyAdmin.

    What could be causing this

    Thanks a lot

    The code...

    PHP Code:
        $inv $_REQUEST['inv'];
        
    $vin $_REQUEST['vin'];
        
    $nmot $_REQUEST['nmot'];
        
    $mar_id $_REQUEST['mar_id'];
        
    $mod_id $_REQUEST['mod_id'];                    
        
    $ano $_REQUEST['ano'];
        
    $ver $_REQUEST['ver'];
        
    $cole_id $_REQUEST['cole_id'];
        
    $coled $_REQUEST['coled'];
        
    $coli_id $_REQUEST['coli_id'];    
        
    $ves_id $_REQUEST['ves_id'];
        
    $pue $_REQUEST['pue'];    
        
    $mot $_REQUEST['mot'];
        
    $tra_id $_REQUEST['tra_id'];
        
    $cla_id $_REQUEST['cla_id'];
        
    $cat_id $_REQUEST['cat_id'];
        
    $km $_REQUEST['km'];
        
    $due $_REQUEST['due'];            
        
    $equa $_REQUEST['equa'];
        
        
    $query "INSERT INTO aut SET
                      inv='
    $inv',
                      vin='
    $vin',
                      nmot='
    $nmot',    
                      mar_id='
    $mar_id',    
                      mod_id='
    $mod_id',                                                              
                      ano='
    $ano',
                      ver='
    $ver',
                      cole_id='
    $cole_id',
                      coled='
    $coled',
                      coli_id='
    $coli_id',    
                      ves_id='
    $inv',
                      pue='
    $pue',
                      mot='
    $mot',                                                  
                      tra_id='
    $tra_id',    
                      cla_id='
    $cla_id',    
                      cat_id='
    $cat_id',
                      km='
    $km',
                      due='
    $due',
                      equa='
    $equa'";    

        
    $result mysql_query($query) or die ("ERROR: " mysql_error()); 
    Last edited by raml; Dec 22, 2006 at 23:57.

  2. #2
    SitePoint Addict
    Join Date
    Sep 2005
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your example did not show a field called mar_id. What field type is mar_id and how big is the integer you are trying to enter?
    PHP Shopping Cart Software Easy Ecommerce Shopping Cart Script.
    PHP Super Cart is 100% template driven.

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You probably have a required column named mar_id for this table, and you're not specifying any value for mar_id in your query.

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did not notice I removed mar_id from the query while doing some tests, but I have included it again in the code.

    mar_id is a tinyint and the integer value I am trying to add varies between 1 and 80.

    on the other hand, mod_id is a smallint and the integer varies between 1 and 400.

    Do you think it could be a bug in MySQL?

    This is how I created the table:

    CREATE TABLE `aut` (
    `id` int(10) unsigned NOT NULL auto_increment,
    `fecha` timestamp NOT NULL default CURRENT_TIMESTAMP,
    `inv` varchar(10) default NULL,
    `vin` char(17) NOT NULL,
    `nmot` varchar(15) NOT NULL,
    `mar_id` tinyint(3) unsigned NOT NULL,
    `mod_id` smallint(4) unsigned NOT NULL,
    `ano` smallint(4) NOT NULL,
    `ver` varchar(30) NOT NULL,
    `cole_id` tinyint(2) NOT NULL,
    `coled` varchar(50) default NULL,
    `coli_id` tinyint(2) NOT NULL,
    `ves_id` int(10) unsigned NOT NULL,
    `pue` tinyint(2) unsigned default NULL,
    `mot` varchar(15) default NULL,
    `tra_id` tinyint(2) unsigned NOT NULL,
    `cla_id` tinyint(2) unsigned NOT NULL,
    `cat_id` tinyint(2) unsigned NOT NULL,
    `km` mediumint(6) unsigned default NULL,
    `due` tinyint(2) default NULL,
    `equa` text,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

    Thanks again

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are you now giving mar_id a value in the correct integer range? You weren't before.


Bookmarks

Posting Permissions

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