Help with inserting date

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with inserting date

    im getting this error

    You have an error in your SQL
    syntax; check the manual that
    corresponds to your MySQL
    server version for the right
    syntax to use near 'key,active)
    VALUES ('test','1306750606',0,0,0,0,'
    mwi35',0)' at line 1

    when im trying to insert this

    $insreg="INSERT INTO p_users (username,time,sent,points,banned,rank,key,active) VALUES('$userid','$date','0','0','0','0','$key','0 ')";
    mysql_query($insreg) or die(mysql_error());
    please tell me guys how to solve this

    #2
    Originally posted by atef View Post
    im getting this error

    You have an error in your SQL
    syntax; check the manual that
    corresponds to your MySQL
    server version for the right
    syntax to use near 'key,active)
    VALUES ('test','1306750606',0,0,0,0,'
    mwi35',0)' at line 1

    when im trying to insert this

    $insreg="INSERT INTO p_users (username,time,sent,points,banned,rank,key,active) VALUES('$userid','$date','0','0','0','0','$key','0 ')";
    mysql_query($insreg) or die(mysql_error());
    please tell me guys how to solve this


    it would be much better if you could Provide the SQL for the table "p_users" because it looks like you are trying to insert "VARCHAR" into "INT" column.

    Comment


      #3
      yup .. i figure out you are trying to insert char into int domain.
      can you please provide the table structure ?
      you can try removing the "space" after the last 0 to see if it works.

      Comment


        #4
        thank you guys i edited database tables and its working now, i was trying to add int at varchar

        Added after 19 minutes:

        wtf
        its back again heres the database structure

        CREATE TABLE `p_users` (
        `id` bigint(99) unsigned NOT NULL auto_increment,
        `username` text,
        `time` bigint(30) unsigned NOT NULL default '0',
        `sent` bigint(1) unsigned NOT NULL default '0',
        `points` bigint(255) unsigned NOT NULL default '0',
        `banned` bigint(1) unsigned NOT NULL default '0',
        `rank` bigint(1) unsigned NOT NULL default '0',
        `key` text,
        `active` bigint(1) unsigned NOT NULL default '0',
        `mobile` text,
        `country` text,
        PRIMARY KEY (`id`)
        ) ENGINE=MyISAM DEFAULT
        CHARSET=latin1
        AUTO_INCREMENT=104;

        and im using this

        $insreg="INSERT INTO p_users (username,time,sent,points,banned,rank,key,active, country) VALUES('$userid','$date','0','0','0','0','$key','0 ','$country')";

        mysql_query($insreg) or die(mysql_error());
        Last edited by atef; 30.05.11, 14:28.

        Comment


          #5
          Originally posted by atef View Post
          thank you guys i edited database tables and its working now, i was trying to add int at varchar

          Added after 19 minutes:

          wtf
          its back again heres the database structure

          CREATE TABLE `p_users` (
          `id` bigint(99) unsigned NOT NULL auto_increment,
          `username` text,
          `time` bigint(30) unsigned NOT NULL default '0',
          `sent` bigint(1) unsigned NOT NULL default '0',
          `points` bigint(255) unsigned NOT NULL default '0',
          `banned` bigint(1) unsigned NOT NULL default '0',
          `rank` bigint(1) unsigned NOT NULL default '0',
          `key` text,
          `active` bigint(1) unsigned NOT NULL default '0',
          `mobile` text,
          `country` text,
          PRIMARY KEY (`id`)
          ) ENGINE=MyISAM DEFAULT
          CHARSET=latin1
          AUTO_INCREMENT=104;

          and im using this

          $insreg="INSERT INTO p_users (username,time,sent,points,banned,rank,key,active, country) VALUES('$userid','$date','0','0','0','0','$key','0 ','$country')";

          mysql_query($insreg) or die(mysql_error());

          The reason why you are getting this error in your SQL syntax is because your insert query is incorrect. as secified in your table "p_users" you have 10 columns and you are only trying to insert 9 the way you are using the query to insert you have to insert the exact number of columns that are in the table "p_users". and if you look at your insert statement you will notice that you are not inserting the field "mobile" so for this to work it must be like this below
          $insreg="INSERT INTO p_users (username,time,sent,points,banned,rank,key,active, mobile, country) VALUES('$userid','$date','0','0','0','0','$key','0 ','$mobile','$country')";

          mysql_query($insreg) or die(mysql_error());

          Comment


            #6
            thank u anthony , i used
            Code:
            $sql = "INSERT INTO `p_users` (`username`, `time`, `sent`, `points`, `banned`, `rank`, `key`, `active`, `mobile`, `country`) VALUES ('$userid', '$date', '0', '3', '0', '0', '$key', '0', '$mobile', '$country');";
            
            mysql_query($sql) or die(mysql_error());
            and its working nw

            Comment

            Working...
            X