Got a little problem in my code, the query works fine if I manually entered the values. But failed if I use my variable. Below is the code
my $get_meter_id = $dbh->prepare("SELECT * from t_readings where meter_serial = '21001652' AND ..."); $get_meter_id->execute() or die "Couldn't execute statement: ".$get_meter_id->errstr; my $meter_reg_id = $get_meter_id->fetchrow_array();
Working on one
where meter_serial = 21001652 AND ...")
Above works.
where meter_serial = '".$variable."' AND ...")
Above does not work
where meter_serial = ".$variable." AND ...")
Above does not work
Many thanks.
source share