I have a Perl script that is running a WMI query against a PC and then populating a MYSQL DB. The problem is that if the returned result has a quote in it like "Daemon's Home" it fails when it goes to do the insert. Here is a sample of my code:
-----------------------------------------------------------
foreach my $PRINFO ( in( $WMIServices->InstancesOf( $WIN32_PR ) ) )
{
$PRNUM = ++$PRNUMCount;
$sth = $db->prepare("UPDATE win32_product set
Vendor='PRINFO->{Vendor}'
WHERE PCID = $PCID AND PRNUM = $PRNUM");
$sth->execute();
}
-----------------------------------------------------------
First, is this a Perl issue or MYSQL issue. I believe it is a MYSQL issue but I can't figure out how to get by this. 'PRINFO->{Vendor} brings back Daemon's Home but then fails in the update. 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 'S HOME'
-----------------------------------------------------------
-----------------------------------------------------------
foreach my $PRINFO ( in( $WMIServices->InstancesOf( $WIN32_PR ) ) )
{
$PRNUM = ++$PRNUMCount;
$sth = $db->prepare("UPDATE win32_product set
Vendor='PRINFO->{Vendor}'
WHERE PCID = $PCID AND PRNUM = $PRNUM");
$sth->execute();
}
-----------------------------------------------------------
First, is this a Perl issue or MYSQL issue. I believe it is a MYSQL issue but I can't figure out how to get by this. 'PRINFO->{Vendor} brings back Daemon's Home but then fails in the update. 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 'S HOME'
-----------------------------------------------------------