SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question String Converted To Strange Value

    Hi guys

    I've created a system that checks inventory on locations at work. Every location is a string value and the items on it are all numeric and no more than 6 characters long. I have a simple function to check the two.

    So, I use a barcode scanner and read in the location and then a list of the items on this location. Then I move on to the next location. The scanner is reading in to a textarea field. Once I'm finished, I go back to the workstation and click done.

    The data is submitted and is exploded using PHP_EOL as the separator. Each line is then checked for whether it's a string or a number. I've found a bug though that has cropped up a couple of times, including this morning:

    The system highlights three types of exceptions:

    1. Items that were found but were not expected
    2. Items that were not found but were expected
    3. Items that were found in the incorrect location

    This morning, a location (AP3) is scanning in OK, but when the exceptions are displayed we saw a few in category 3: Items that should've been on location "AP3", were actually on location "3/1010". I don't know what this means but this has come up a couple of times now and we've had to manually correct these faults. I don't even know where to start looking for this.

    We're running the following:

    Apache 2.2.8
    MySQL 5.0.51a
    PHP 5.2.5

    If any more information will help solve the mystery then please ask and I'll do my best to provide it. Any and all help is gratefully received.

    Thanks guys

  2. #2
    SitePoint Addict X-Cart's Avatar
    Join Date
    May 2009
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am afraid without the code itself it won't be possible to say what is wrong. If you could provide the code that parses the values that would be easier.
    X-Cart - tens thousands live online shops worldwide
    Follow us on Twitter

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Lets see if this is any help:

    Code PHP:
            $listed    = explode(PHP_EOL, $_POST['shelfcheck']);
            foreach($listed AS $key => $val){
                $val    = trim($val);
                if ($loc->unitorlocation($val) === FALSE){
                    $location = strtoupper($val);
                    unset($jobno);
                } elseif($loc->unitorlocation($val) === TRUE) {
                    $jobno    = $val;
                    $in        .= "$val, ";
                }
                if ($jobno && $location){
                    $jobarr[$jobno] = $location;
                }
            }
    Is that of any help? The information in $_POST['shelfcheck'] is fine, but for some reason it changes to the value above throughout this loop

  4. #4
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    OK, so I've checked through the database and found a few instances where the desired location has been replaced with another:

    AP2 became 32879%
    AP3 became 3/1010
    AP7 became 3774J7
    AP63 became _@63

    Why?
    Last edited by Antnee; Jul 9, 2009 at 04:53.

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post the output of
    PHP Code:
    echo base64_encode($_POST['shelfcheck']); 
    btw, PHP_EOL isn't meant to match user input. Better would be
    PHP Code:
    $lines preg_split('#\r\n|\r|\n#'$foo); 

  6. #6
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I have changed explode() to preg_split() and I've still got the same problem. On further examination however I feel like a bit of a plank. I'd not noticed that the locations were actually malformed item numbers. A scan today changed item number 380032 in to 380%32, amongst others.

    I have set the system up to record the scanned items in a text file on the server, which is recorded when the information is POST'd to the next page, so either the data is corrupted during POST, or it is scanned in incorrectly, which could indicate a problem with the scanner, or the barcode.

    I've asked the team leader responsible to save the actual scanned list before POST so that we can see if there is data corruption before or after POST, but in the mean time, has anyone come across the problem where data is corrupted during POST, especially with large textarea inputs?

    Thanks guys

  7. #7
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It appears that it's the scanners after all. Good quality wireless scanners, but they're being used at a huge range, and with a lot of interference around.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •