Hello, I was wondering if anyone knows PERL & DBI, if so please respond to [EMAIL PROTECTED] personally, or to the list....
My question is, I'm trying to build a 'custom' querier for a survey program... based on the information submitted, the program will generate an SQL Query statement. The command that my program works absolutely find if I copy/paste it into MySQL, however, DBI won't pass it... if I pass the QUERY Along to DBI typed in manually it works... Any Idea's? Here is a copy of the block of code #Attempt to build an artificial SQL Query ######################################### $i=0; if($vars{'f_name'} ne "") { @query[0] = "AND `f_name` = \'$vars{'f_name'}\'"; $i++; } if($vars{'l_name'} ne "") { @query[$i] = "AND `l_name` = \'$vars{'l_name'}\'"; $i++; } if($vars{'stud_num'} ne "") { @query[$i] = "AND `stud_num` = \'$vars{'stud_num'}\'"; $i++; } if($vars{'grade'} ne "") { @query[$i] = "AND `grade` = \'$vars{'grade'}\'"; $i++; } foreach $item(@query) { $dastring = join(" ",$dastring,$item); #$end = "\""; #$dastring = join("",$dastring,$end); } #print "Dum Dum Dum... The query is <b>$dastring</b>\n"; #Build the remaining query string $first_part = "SELECT `level`,`f_name`,`l_name`,`stud_num`,`grade`,`last_survey` FROM `users` WHERE 1"; $finalstring = join(" ", $first_part,$dastring); print "The Final Product <b>$finalstring</b>\n"; ############################################# #End of Artificial Query #Connect to the SQL Server specified in the %sql hash $dbh = DBI->connect("dbi:mysql:$sql{'database'}", "$sql{'username'}", "$sql{'password'}"); #Pepare an SQL Query for execution $sth = $dbh->prepare($finalstring); #Executes the SQL Command in the previous statement $rc = $sth->execute; #executes the search #my $row_hash; #defines $row_hash as a local variable. #Grab and breakup the row hash #while($row_hash = $sth->fetchrow_hashref) { $vars{'f_name'}=$row_hash->{f_name}; #Loads the Username $vars{'l_name'}=$row_hash->{l_name}; #Loads the password $vars{'stud_num'}=$row_hash->{stud_num}; #Loads the Student # $vars{'grade'}=$row_hash->{grade}; #loads the grade $vars{'l_survey'}=$row_hash->{last_survey}; #loads the date of the last $vars{'level'}=$row_hash->{level}; #Grabs the user level print <<endofhtml; <tr> <td>$vars{'f_name'}</td> <td>$vars{'l_name'}</td> <td>$vars{'stud_num'}</td> <td>$vars{'grade'}</td> <td>$vars{'l_survey'}</td> <td>$vars{'level'}</td> </tr> endofhtml } $sth->finish; #finishes the SQL Query $dbh->disconnect(); #Disconnect the database to save connections Any assistance that can be provided is much appriated as this code is for my school's survey program Thanks Kevin