http://qs1969.pair.com?node_id=796790

vendion has asked for the wisdom of the Perl Monks concerning the following question:

I'm sure that you heard enough of DBD::mysql but I am wanting to ask a question on a problem and needing someone who knows perl to bounce ideas off of.

First of all the script that I am working on runs fine until it gets the point where it needs to insert data into the mysql server. The error that I get is as follows:

DBD::mysql::db do 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 '(Dell, Optiplx , 600 , WinXP , None , fixing , Slow , 000-0001 , password' at line 1 at repairs.pl line 110, <STDIN> line 14. DBD::mysql::db do 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 '(Dell, Optiplx , 600 , WinXP , None , fixing , Slow , 000-0001 , password' at line 1 at repairs.pl line 110, <STDIN> line 14.

Here is my code as of now

#!/usr/bin/perl use strict; use warnings; use DBI; #Declaire all variables now! my $customer_firstname; #Store the customers first name my $customer_lastname; #Store the customers last name my $customer_phone; #Store the customers main phone number my $customer_email; #Store the customers email address my $customer_date; #date that the entry was made my $customer_AcceptTerm; #Accept Term of use? my $customer_compman; #Store the computer manufaturer my $customer_compmodel; #Store the computer model my $customer_compModelNum; #Store the computer model number my $customer_errormsg; #Store any and all error messages displaied my $customer_os; #Store what OS is being used my $customer_probdesc; #Store the problem description my $customer_loginpw; #Store the password for the admin/root user my $customer_service; #Store what services need to be done. my $customer_barcode; #Store the barcode for the computer. my $database = "Repairs"; #Specify the database to be used my $hostname = "192.168.1.111"; #Connect to the MySQL server my $port = '3306'; #MySQL port my $user = 'csccrepairs'; #MySQL username my $password = 'repairshop'; #MySQL password my $dsn; my $dbh; system("clear"); #system("clear") only works on Unix based systems, ne +ed to come up with #something that works on windows print "Cleveland State CC Computer Repairs\n\n"; print "Version 0.2\n", "Copyleft 2009 Adam Jimerson & Andy Arp\n"; main(); #break here sub main() { print "----------------------------\n", "Main Menu, To make a selection specify the number for that ac +tion\n"; print "1. Add New Computer to Database\n"; print "2. Edit Computer Status in Database\n"; print "3. Remove a Computer from Database\n"; print "4. Look up Computer Information\n"; print "5. List All Repair Requests\n"; print "Action: "; my $option = <STDIN>; chomp($option); if ( $option eq '1' ) { print_form(); } else { die "Unknown Action: $option\n"; } } sub print_form { print "\nCustomer Information\n", "-----------------------\n"; #Begin the customer information f +orm print "Customer First Name: "; $customer_firstname = <STDIN>; chomp($customer_firstname); print "Customer Last Name: "; $customer_lastname = <STDIN>; chomp($customer_lastname); print "Customer Phone #: "; $customer_phone = <STDIN>; chomp($customer_phone); print "Customer Email: "; $customer_email = <STDIN>; chomp($customer_email); print "\nComputer Information\n", "-----------------------\n"; #Begin the computer information f +orm print "Computer Manufacturer: "; $customer_compman = <STDIN>; chomp($customer_compman); print "Computer Model: "; $customer_compmodel = <STDIN>; chomp($customer_compmodel); print "Computer Model #: "; $customer_compModelNum = <STDIN>; chomp($customer_compModelNum); print "Error Message (if any): "; $customer_errormsg = <STDIN>; chomp($customer_errormsg); print "Operating System: "; $customer_os = <STDIN>; chomp($customer_os); print "Problem Description: "; $customer_probdesc = <STDIN>; chomp($customer_probdesc); print "Administrator/Root Login Password: "; $customer_loginpw = <STDIN>; chomp($customer_loginpw); print "Computer Service Needed: "; $customer_service = <STDIN>; chomp($customer_service); print "Barcode Number: "; $customer_barcode = <STDIN>; chomp($customer_barcode); $customer_date = system('date'); db_add(); } sub db_add { #Insert values retreived from print_form() $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port"; $dbh = DBI->connect($dsn, $user, $password, {RaiseError => 1}); $dbh->do("INSERT INTO Repairs.computers VALUES (compManufacturer, +compModel, compModelNum, OS,errorMsg , serviceNeeded, problemDescript +ion, barcode, password) ($customer_compman, $customer_compmodel , $cu +stomer_compModelNum , $customer_os , $customer_errormsg , $customer_s +ervice , $customer_probdesc , $customer_barcode , $customer_loginpw") +; $dbh->do("INSERT INTO Repairs.customers VALUES(firstname, lastname +, email, phone, date) ($customer_firstname, $customer_lastname, $cust +omer_email, $customer_phone, $customer_date"); $dbh->disconnect(); } exit 0;

As far as what I need to bounce off someone is order to cut down on the number of scalier variables will the use of hashes further mess up DBD::mysql?