Viswanatha Rao wrote:

I am trying to populate a table row in mysql.
my $sla_id=”100”;
my $node_type=”127.0.0.1”;
my $operation_type = “add a node”;

my $id = $dbh->quote($sla_id);
my $nodeid = $dbh->quote($node_type);
my $operation = $dbh->quote($operation_type);

The insert works with this piece of code:

my $sth = $dbh->prepare("insert into myTable(ID, NodeID, Operation_Type) values ($id, $nodeid, $operation)");

here you use $id, $nodeid and $operation.

$sth->execute();

Whereas, if I use this cryptic version, insert fails without error:

$dbh->do("insert into myTable(ID, NodeID, Operation_Type) values(?,?,?)", undef, (param($id), param($nodeid), param($operation) ));

here you use param($id) etc. Change this to

$dbh->do("insert into myTable(ID, NodeID, Operation_Type) values(?,?,?)", undef, $sla_id, $node_type, $operation_type);

Note that there is no need to call dbh->quote on those.

Can someone tell me why the second version fails and how to fix it? Also I don’t know what param does?

My guess would be is that it comes from the CGI module. It pulls out cgi query variables passed to your script. It's highly likely there are no parameters named "127.0.0.1" etc, so your query is called with empty values.


HTH,

Rhesa
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to