why my values are not getting inserted into database please someone help me out

+2 MANJOT SINGH · March 27, 2015
I created a table writing this sql code

CREATE TABLE IF NOT EXISTS `users`(
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(32) NOT NULL,
`sign_up_date` date NOT NULL,
`activated` enum('0', '1') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

and table was created successfully but when i am trying to insert data into it through registry form its not getting inserted

i have used the query below to insert value into it

$query = mysql_query("INSERT INTO users VALUES('','$fn','$ln','$un','$em','$pswd'.'$d','0')");

please someone help me out

Post a Reply

Replies

Oldest  Newest  Rating
+2 Altaf Husain Neva · March 27, 2015
Try This:


$query = mysql_query("INSERT INTO users VALUES('','$un','$fn','$ln','$em','$pswd','$d',0)");


Instead of this:


$query = mysql_query("INSERT INTO users VALUES('','$fn','$ln','$un','$em','$pswd'.'$d','0')"); 


I mean you have a syntax error between $pswd and $d, you have used '.'(dot) instead of ','(comma)

Plus according to me it is a better practice to specify the column names and than values to stay away from silly errors.
+1 oleh kovalyk · March 28, 2015
try this

$query = mysql_query("INSERT INTO users(id,username,first_name,last_name,email,password,sign_up_date,activated) VALUES('$un','$fn','$ln','$em','$pswd','$d','0');");
+1 oleh kovalyk · March 28, 2015
And .. I can reccomend you to use PHPMYADMIN ... Whit this software you can test your query and if this query has some problem him signing this problem
+1 James Juan · March 27, 2015
, .i think when dealing with variables you cannot just put it inside ''. 

VALUES(' & ($fn) & ')

something like that.
0 Sho Carter · April 1, 2015
$query = mysql_query("INSERT INTO users VALUES('','$fn','$ln','$un','$em','$pswd'.'$d','0')"); 

You placed a full stop instead of a comma. (I highlighted in bold).
  • 1

SQL & Databases

107,252 followers
About

Everything SQL and Databases related in here!

Links
Moderators
Bucky Roberts Administrator