ervisboy007 Posted March 3, 2010 Share Posted March 3, 2010 Hi, $tableSQL = "CREATE TABLE Members ( UserName varchar(15), PassWord varchar(15), EMail varchar(15), JoinDate varchar(15) )" $sqlquery = "INSERT INTO Members (UserName, PassWord, EMail, JoinDate) VALUES($username, $password, $email, $joindate)"; When I use my form to register an account, I get this: "An error occured: 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 '@hotmail.com, 03-Mar-2010)' at line 2" Here is the site if you want to take a look at: http://cegames.megabyet.net/Sancum/register.html Thanks, Ervisboy007 EDIT: MySQL version 5.0.87-community-log PHP version 5.2.11 Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/ Share on other sites More sharing options...
mapleleaf Posted March 3, 2010 Share Posted March 3, 2010 varchar(15) won't be enough for email Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021107 Share on other sites More sharing options...
ervisboy007 Posted March 3, 2010 Author Share Posted March 3, 2010 Hi, I change it to varchar(45) but I still think that that's not the problem. An error occured: 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 '@hotmail.com, 03-Mar-2010)' at line 2 does MySQL have a special datatype for emails? maybe the '@' is causing the problem? could it be that my table is setup wrong? Thanks, Ervisboy007 Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021110 Share on other sites More sharing options...
mapleleaf Posted March 4, 2010 Share Posted March 4, 2010 No @ is allowed in varchar so not that echo out your $email variable and see what you get Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021155 Share on other sites More sharing options...
ervisboy007 Posted March 4, 2010 Author Share Posted March 4, 2010 Hi, this is what I get: username, password, email, joindate tester test [email protected] 04-Mar-2010 An error occured: 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 '@hotmail.com, 04-Mar-2010)' at line 2 Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021404 Share on other sites More sharing options...
ervisboy007 Posted March 4, 2010 Author Share Posted March 4, 2010 SOLVED: $sqlquery = "INSERT INTO Members (UserName, PassWord, EMail, JoinDate) VALUES('$username', '$password', '$email', '$joindate')"; yes, the problem were the single quotations -- i forget them Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021427 Share on other sites More sharing options...
fenway Posted March 4, 2010 Share Posted March 4, 2010 Actually, not solved -- you're storing dates as VARCHAR -- not DATE -- use a proper format. Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021459 Share on other sites More sharing options...
ervisboy007 Posted March 4, 2010 Author Share Posted March 4, 2010 Hi, thanks for the warning, but now, I have another error 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 'CURDATE(), PRIMARY KEY (MemberID) )' at line 7 $tableSQL = "CREATE TABLE Members ( MemberID int(11) unsigned NOT NULL auto_increment, UserName varchar(30) NOT NULL default '', PassWord varchar(32) NOT NULL default '', EMail varchar(50), JoinDate date NOT NULL DEFAULT CURDATE(), PRIMARY KEY (MemberID) )"; $sqlquery = "INSERT INTO Members (UserName, PassWord, EMail) VALUES('$username', '$password', '$email')"; Should I use unsigned for the JoinDate too? Thanks, Ervisboy007 Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021540 Share on other sites More sharing options...
xcoderx Posted March 5, 2010 Share Posted March 5, 2010 i guess whenever there is a text field quotation is must :-) Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021815 Share on other sites More sharing options...
xcoderx Posted March 5, 2010 Share Posted March 5, 2010 yes u have to assign joindate too if im not wrong. Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1021816 Share on other sites More sharing options...
fenway Posted March 7, 2010 Share Posted March 7, 2010 And you can't use an expression as a default. Link to comment https://forums.phpfreaks.com/topic/194061-mysql-email-datatype/#findComment-1022696 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.