Mysql error:Duplicate entry '.' for key 'PRIMARY'

S

Saptarshi Nag

Guest
I have written a php script and the following mysql error is coming
Duplicate entry '.' for key 'PRIMARY'
The code is as follows---
$name=$_POST["name"];
$eid=$_POST["id"];
$year=$_POST["year"];
$dept=$_POST["department"];
$un=$_POST["username"];
$pass=$_POST["password"];
$regdata="INSERT INTO user_table(Fullname,Email,Year,Dept,Username,Password) VALUES('.$name.','.$eid.','.$year.','.$dept.','.$un.','.$pass.')";
mysql_connect("localhost","root","password") or die(mysql_error());
mysql_query("CREATE DATABASE IF NOT EXISTS user_db") or die(mysql_error());
mysql_select_db("user_db") or die(mysql_error());
mysql_query("CREATE TABLE IF NOT EXISTS user_table(
Fullname CHAR,
Email CHAR
Year CHAR,
Dept CHAR,
Username CHAR,
Password CHAR,
PRIMARY KEY(Username)") or die(mysql_error());
mysql_query($regdata) or die(mysql_error());
mysql_close();
 
Last edited:


hmm. should
Code:
PRIMARY KEY(Username)") or die(mysql_error());
be
Code:
PRIMARY KEY("(Username)") or die(mysql_error());
 
hmm. should
Code:
PRIMARY KEY(Username)") or die(mysql_error());
be
Code:
PRIMARY KEY("(Username)") or die(mysql_error());
No there's no problem with that.the closing double quote has the starting one in "CREATE TABLE...
 

Members online


Top