in reply to Error in $sth->execute()

Hello ravi45722,

You don’t show what values $preference might take, but this line looks strange to me:

if ( $preference =~ tr/0//) #if preference is 0 make all category as + 0

Say the value of $preference is the string "10405". The transliteration will find the two zero characters, leave them alone (since no replacement is specified), and return a value of 2 — and therefore the if statement will evaluate to true. See the discussion in perlop#Quote-Like-Operators.

Maybe this is what you intended, but, as I said, it looks strange.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Error in $sth->execute()
by ravi45722 (Pilgrim) on Feb 20, 2016 at 04:29 UTC
    The input is very strict & the preferences data is like
    0 #if zero comes no other value is present 1 #single category (it very vary from 1..7) 1#2#3 #multiple category