Jump to content

[SOLVED] Barcode leading zero being dropped - database entry therefore incorrect


fj1200

Recommended Posts

Hi - hope someone can save my sanity here.  I have a barcode - interleaved 2 of 5 (required as a 2nd barcode is also an industry std I 2 of 5) in the form 09010202.  It is made up of pairs if digits which I then split out in the php web page thus:

 

//SITE BARCODE BREAKDOWN

$bc_site=substr($_POST[rs_barcode],0,2);  <------ causing me problems!!

$bc_press=substr($_POST[rs_barcode],3,2);

$bc_reelstand=substr($_POST[rs_barcode],5,2);

$bc_arm=substr($_POST[rs_barcode],7,2);

 

The first row arrowed is causing the issue.  I need the leading zero included as it throws everything else out.  This is then inserted into a MySQL database.  All works fine except than it has started to drop the first zero.  I can cope with that in the database using the zerofill option, but in the above example I end up with $bc_press = 90 instead of 09, which then screws up my lookups for the reports.  It was working, and now it isn't.  Can anyone shed any light on it please?

Typical isn't it!!  Soon as I post a question I get it working!

 

//SITE BARCODE BREAKDOWN

$bc_site=substr($_POST[rs_barcode],0,2);

$bc_press=substr($_POST[rs_barcode],2,2);

$bc_reelstand=substr($_POST[rs_barcode],4,2);

$bc_arm=substr($_POST[rs_barcode],6,2);

 

Already tried that and it didn't work though!  I dunno - sometimes I hate computers!  The first pair were definately causing me issues - the only changes are after that, but I wasn't getting '01' in the database I was getting '10' but it's now seeing the first zero.  Can anyone suggest what I've done to make it work cos I have no idea!  :-[

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.