in reply to Unable to pass 0 number through form with CGI DBI backend

Consider:

use strict; use warnings; my $mob = '070222000123'; print "$mob\n"; $mob =~ s/[:;$%&@<>?]//gi; print "$mob\n";

Output

070222000123 7222123

You strip them out before you do anything database related. Basic debugging can include simply printing data to the screen so you know that it is what you expect it to be. Basic debugging checklist.

Replies are listed 'Best First'.
Re^2: Unable to pass 0 number through form with CGI DBI backend
by ramachandrajr (Novice) on Sep 12, 2015 at 10:52 UTC
    thats okay but in future if we may need contact info from db we r not gonna get the right number

      Consider using a list of allowed characters with negation.

      $mob =~ s/[^0-9-]//gi;
      poj
        that actually worked what do you think was the problem behind it i was just trying to block symbols not numbers using replacement.then why did that happen
        thanks man goodbye cya soon

      Sure, if you throw away data before inserting it into your database, when you query the database in future the data in quesiton won't be there. I'm not sure what you expect. Likely your post does not properly describe your problem.

        i want to keep the zeros in the field as zeros ,i dont wanna loose them suppose some one enters 7890123456 ,in db also it should be 7890123456 (!)not 789123456 . Now how can i not lose those zeros when passing from a cgi script 7890123456 ->turns into->789123456.Thats not what i want i want perfectly intact data