Advertisement

03.27.2008 at 01:23PM PDT, ID: 23275513
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.8

DBD::mysql::st error on '_self in my Perl script.

Asked by Murfect in Perl Programming Language, MySQL Server

Tags: , ,

I'm doing a table-wide search and replace in Mysql using Perl. I just started getting DBD::Mysql errors on some of the content I mean to be removed entirely.

Here is the error:
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 '_self" href="/schools/e/example/images/stylemanager/banner/../../../info">Change' at line 1 at /data/wre/prereqs/perl/lib/site_perl/5.8.8/i686-linux/Mysql.pm line 175.

and below is the code. The error is being triggered by the content in wo.description I think.

What I'm doing is:

1) Pulling in a field from the database
2) Search & Replace for a bad link
3) Search & Replace for a bad list item
4) Building my sequel with the augmented field
5) Updating database



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
$connect->selectdb($database);
my $query = $connect->query($sql_query);
while (my @results = $query->fetchrow())		
	{
		### Setting Sequel Vars
		my $url = shift(@results);
		my @site = split('/', "$url");
		my $description = shift(@results);
		my $assetId = shift(@results);
		my $revisionDate = shift(@results);
		print   LOG  "$timeStamp ::: INITIAL URL:  $url  :::  ASSET ID: $assetId  REVISIONDATE: $revisionDate";
		
		### Setting Search & Replace Vars
		my $search = '( .*)(<li>.*(will display randomly).*?<\/li>)';
		my $linkSearch = '<p>\s*<a href=".*" target=".+self">Change Your Image Settings&nbsp;<\/a>\s*<\/p>';
		my $empty = '';
		my $update = $description;
		
		###Search & Replace Unused Link
		if ($update =~ s/$linkSearch/$empty/igsm) {
				print LOG "::: <A> REPLACED ###"; } else { print LOG "::: <A> NOT FOUND ###"; }
		###Search & Replace Incorrect List Item
		if ($update =~ s/$search/$1/igsm) {
				print LOG " ::: <LI> REPLACED ###";
				
				### Build Update Sequel
				my $sql_update = "UPDATE  wobject wo SET wo.description=\"$update\" WHERE wo.revisionDate = \"$revisionDate\" AND wo.assetId=\"$assetId\";";
				### UPDATE field
				if ($connect->query(qq{$sql_update}) or die ("print LOG $Mysql::db_errstr\n")) { print LOG " UPDATE SUCCESS### \n";}
			} else { print LOG "::: PATTERN NOT FOUND ### \n";}
	}
[+][-]03.27.2008 at 01:59PM PDT, ID: 21225706

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Perl Programming Language, MySQL Server
Tags: Perl mysql, 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 '_self" ..., perl mysql linux error
Sign Up Now!
Solution Provided By: Adam314
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.28.2008 at 08:29AM PDT, ID: 21231276

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.28.2008 at 08:56AM PDT, ID: 21231535

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.28.2008 at 10:10AM PDT, ID: 21232258

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628