Help with inserting date

Started on the old forum in May 2011 · view the original in the archive · old links redirect here

5 replies · 400 views · started 15 years ago · 1 min read

3 participants
atef Developer · 224 posts #1

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

Anthony Developer · 82 posts #2

atef wrote: 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.

FREE International SMS

GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....

http://gysms.com

Send FREE International MMS and Share Files worldwide using our MMS Service.

http://gysms.net

GTriddim Live Online Radio Station

http://www.gtriddim.com

arpan.rnc Developer · 94 posts #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.

atef Developer · 224 posts #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());

Anthony Developer · 82 posts #5

atef wrote: 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());

FREE International SMS

GYSMS.com Provides FREE International sms Reach over 775 networks in more than 221 countries at no cost to you. and the Good News is we own our SMS Hardware so there is no third party SMS API involved our services are completely Ad supported.....

http://gysms.com

Send FREE International MMS and Share Files worldwide using our MMS Service.

http://gysms.net

GTriddim Live Online Radio Station

http://www.gtriddim.com

atef Developer · 224 posts #6

thank u anthony , i used

$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

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close