Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie database help 1

Status
Not open for further replies.

Supra

Programmer
Dec 6, 2000
422
US
I am EXTREMELY new to SQL, so please bear with me. This is the code I have..
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();
..and this is the error I get:
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.
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.
 
put your strings inside quotes

VALUES ( $UID, '$PWD', '$HANDLE', '$FNAME', '$LNAME',
$GENDER, $BDAY, $BMONTH, $BYEAR, '$EMAIL' )

can you tell from this which ones i thought were supposed to be numeric?


r937.com | rudy.ca
 
That did it! Thanks a ton and a star for you!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top