I am EXTREMELY new to SQL, so please bear with me. This is the code I have..
..and this is the error I get:
I'm assuming the error is due to the @ sign in the email address I am testing to sign up at my website with, but I'm not sure. I have all the fields set as type TEXT in my table. I know this code is poor at best, but like I said, I'm EXTREMELY new to SQL. In fact, I've never once attempted to use it. Any guidance is much appreciated, as tutorials only seem to be spinning me in circles.
Code:
# Go through database and look for this email
$driver = DBI->install_driver("mysql");
$dsn = "DBI:mysql:database=TEST;host=mysql127.secureserver.net";
$db = DBI->connect($dsn,"USER1","PASSWORD1");
my $query = $db->prepare("SELECT * FROM Members");
$query->execute();
while (my @row = $query->fetchrow_array()) {
my ($Username,$Password,$Handle,$FirstName,$LastName,$Gender,$BirthDay,$BirthMonth,$BirthYear,$Email) = @row;
if ($Email eq $EMAIL) {
dienice("Sorry, that email has already been registered. Please try a different email address.");
}
}
$query->finish();
$db->disconnect();
# Now create the account
$driver = DBI->install_driver("mysql");
$dsn = "DBI:mysql:database=TEST;host=mysql127.secureserver.net";
$db = DBI->connect($dsn,"USER1","PASSWORD1");
my $query = $db->prepare("INSERT INTO Members (Username,Password,Handle,FirstName,LastName,Gender,BirthDay,BirthMonth,BirthYear,Email) VALUES ($UID,$PWD,$HANDLE,$FNAME,$LNAME,$GENDER,$BDAY,$BMONTH,$BYEAR,$EMAIL)");
$query->execute();
$query->finish();
$db->disconnect();
Code:
DBD::mysql::st execute failed: 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 '@gmail.com)' at line 1 at register.pl line 197.