Arrays performance - 1d vs 2d

Which solution is faster:
int[][] tab = new int[100][100];
tab[x][y] = c;or:
int[] tab = new int[10000];
tab[y*100+x]=c;I know that the second solution is recomended, but it requires one multiplication.
In the first solution compiler can store pointers to second dimension table in first dimension. Pointers have size of 2^n. Integers in second dimension are also of size 2^n. So theoretically compiler may produce byte code that will need no multiplication but only very fast bit-shift operations.
My question is - how does the compiler cope with 2d arrays.
I'm posting my question here because I don't understand bytecode so well. I'm looking for theoretical answer, not benchmark result for specific mobile device.

If I understand right, the problem with that code for the distance matrix is that I dont want to recalculate every row with each iteration, just merge 2 rows from the original distance matrix into 1...and also I cant pick and choose which rows I am merging. There is another function that tells me which rows I have to merge. I could do it with a regular 2d array, but then I need to either shift all the rows each time i merge/remove a row, or I have to keep track of which rows in the matrix i am still using...that would be more complicated than just doing an arrayList of arrayLists I think.
Thanks for the pointer on the arrayList of arrayLists....i'm gonna try to use that for the distanceMatrix. Do you think I lose anything (efficiency or memory) by implementing the 2d arrays the way I have, rather than the arraylist for the expressionMatrix?

Similar Messages

  • Copying arrays, performance questions

    Hello there
    The JDK offers several ways to copy arrays so I ran some experiments to try and find out which would be the fastest.
    I was measuring the time it takes to copy large arrays of integers. I wrote a program that allocates arrays of various sizes, and copy them several times using different methods. Then I measured the time each method took using the NetBeans profiler and calculated the frequencies.
    Here are the results I obtained (click for full size):  http://i.share.pho.to/dc40172a_l.png
    (what I call in-place copy is just iterating through the array with a for loop and copying the values one by one)
    I generated a graph from those values:  http://i.share.pho.to/049e0f73_l.png
    A zoom on the interesting part: http://i.share.pho.to/a9e9a6a4_l.png
    According to these results, clone() becomes faster at some point (not sure why). I've re-ran these experiments a few times and it seems to always happen somewhere between 725 and 750.
    Now here are my questions:
    - Is what I did a valid and reliable way to test performances, or are my results completely irrelevant? And if it's not, what would be a smarter way to do this?
    - Will clone be faster than arraycopy past 750 items on any PC or will these results be influences by other factors?
    - Is there a way to write a method that would copy the array with optimal performances using clone and arraycopy, such that the cost of using it would be insignificant compared to systematically using one method over the other?
    - Any idea why clone() can become faster for bigger arrays? I know arraycopy is a native method, I didn't try to look into what it does exactly but I can't imagine it's doing anything more complicating than copying elements from one location in the memory to another... How can another method be faster than that?
    (just reminding I'm copying primitives, not objects)
    Thanks!
    Message was edited by: xStardust! Added links, mr forum decided to take away my images

    yeh, everyone thinks that at some point. it relies,
    however, on you being perfect and knowing everything
    in advance, which you aren't, and don't (no offence,
    the same applies to all of us!). time and time again,
    people do this up-front and discover that what they
    thought would be a bottleneck, isn't. plus,
    the JVM is much smarter at optimizing code than you
    think: trust it. the best way to get good performance
    out of your code is to write simple, straightforward
    good OO code. JVMs are at a point now where they can
    optimize java to outperform equivalent C/C++ code
    (no, really) but since they're written by human
    beings, who have real deadlines and targets, the
    optimizations that make it into a release are the
    most common ones. just write your application, and
    then see how it performs. trust me on this
    have a read of
    [url=http://java.sun.com/developer/technicalArticles/I
    nterviews/goetz_qa.html]this for more info anda chance to see where I plagiarized that post from :-)
    Thanks for that link you gave me :)
    Was usefull to read.
    About time and money of programming, that is not really an issue for me atm since i'm doing this project for a company, but through school (it's like working but not for money).
    Of course it should not last entirely long but I got time to figure out alot of things.
    For my next project I will try to focus some more on building first, optimizing performance later (if it can be done with a good margin, since it seems the biggest bottlenecks are not the code but things outside the code).
    @promethuuzz
    The idea was to put collection objects (an object that handles the orm objects initialized) in the request and pass them along to the jsp (this is all done through a customized mvc model).
    So I wanted to see if this method was performance heavy so I won't end up writing the entire app and finding out halve of it is very performance heavy :)

  • 2540 array performance

    I have a 2540 array and I'm monitoring it using CAM. I suspect the write speed to my volumes are slow. I've looked at the performance statistics in CAM, but it doesn't seem to give me the write speed. Below is a sample of the statistics I'm getting
    Timestamp: Fri Mar 06 12:33:33 GMT 2009
    Total IOPS: 416.83
    Average IOPS: 157.08
    Read %: 90.74
    Write %: 9.25
    Total Data Transferred: 14359.20 KBps
    Read: 14065.17 KBps
    Average Read: 4376.78 KBps
    Peak Read: 16570.53 KBps
    Written: 294.03 KBps
    Average Written: 126.59 KBps
    Peak Written: 294.03 KBps
    Average Read Size: 271.64 KB
    Average Write Size: 26.05 KB
    Cache Hit %: 24.08
    Does anyone know how I can determine of my write speed is slow or not.
    Thanks

    To determine if the array is running slowly, you need to really check on the servers.
    Run 'iostat -zxn 60' (assuming Solaris)
    The thing you're looking for is a high busy %age, high service time and a large number of requests in the queue. Either on their own is not really sufficient to point at a performance issue but both together would show that all is not well.
    There's usally a lot more to it than that but that can give you a fair indication of potential problems.
    You're showing quite high transfer sizes (writing avg 26K and reading an avg of 272K) - what profile did you use to create the volumes you're accessing here?

  • LabVIEW array performance: Two loops operating on the same massive array

    Yes there has been a lot said and left unsaid about LabVIEW performance in the past - but I have to ask the following:
    Is it possible to have two seperate while loops act on the same data without making copies?
    Say I have a 1GB array of doubles which I have wired to a shift register on one loop.  With a little bit of effort (by using in-place and chasing the dots a bit) it would be possible to operate on that data inside that loop without making copies.
    But what if I need to also access that same array in a different loop (which is running at a different rate).  I basically need two loops' shift registers to point to the same data.  At the moment the only way I can manage this is to use DLL calls which destroys dataflow but al least makes no copies.  It also means I cannot use LabVIEW code but have to resort to C coding.   
    Data corruption is no issue as the two loops, at any instant, operate in different locations of the array.
    Any smart ideas that will work?

    drclaw wrote:
    Hi AnthonV,
    A Functional Global approach might suit your needs. This will allow you to keep you data in a shift register, but access/modify parts of the data from other VIs or loops.
    Another option is to use a single element queue to store the array to achieve a similar result.
    Both these options and more techniques are located at
    http://zone.ni.com/devzone/cda/tut/p/id/3625#toc0 
    Hope that helps 
    Good suggestion. Functional Globals also go by the name "Action Engine" as I discuss in this Nugget on Action Engines.
    Put all of your number crunching code inside appropriately named Actions of the AE and that way all of the work CAN be done "in-place".
    Have fun! 
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Array performance monitoring

    I need some software to monitor Sun's arrays (2540/6140). The software should
    save all the historical data so in case of any performance problems we can see
    its performance day/week/month ago.
    Does Sun has any such software ?

    CAM is free of charge.
    We sell also Santricity (I said sell, yes, this isn't free of charge, there is annual contract to use Santricity) BUT only under specific criteria which can certainly be explained by your Sun Sales representative.
    You will certainly hear people saying that Santricity is better than CAM, or CAM is better than Santricity. Actually, there are different, but we work hard to implement the same functionalities in CAM than what we have in Santricity. We have a number of bug and RFE (request for enhancement) and CAM will even become better in the future, all this can be done because we own CAM and we develop CAM, which isn't the case for Santricity.
    CAM comes by default with all new ST6000 and ST2500 arrays and again, at free of charge.
    If you need any other information about one or the other, do not hesitate to contact your Sun Sales representative.
    Regards

  • Vector vs Array performance?

    Hi, I've heard some ppl says that Vector is slower than Array. Does anyone know what's the different in speed between using an array and a vector?
    Say with the same algorithm, the one uses array take 10s for 1mil iteration, how long with it take for vector?
    Thanks...

    For what it's worth adding 10K strings to various collections and accumulating 1000 results, this is what I saw:
    Vector() 0.69/0.53:
    ArrayList() 0.84/0.69:
    HashSet() 2.15/0.36:
    Vector(SZ) 0.70/0.53:
    ArrayList(SZ) 0.25/0.43:
    HashSet(SZ) 1.56/0.52:
    LinkedList() 0.86/0.60:
    A slight win to Vector unless the collections have their initial size set, in which case ArrayList comes out ahead.
    Things are a little bit different using 500K strings and doing fewer runs (in both cases I didn't time the first two runs):
    Vector() 46.20/7.77: 50 38 49 38 50 63 49 38 49 38
    ArrayList() 51.60/6.00: 50 48 51 47 51 69 52 49 51 48
    HashSet() 662.30/31.28: 648 652 652 651 652 756 652 653 652 655
    Vector(SZ) 14.90/0.30: 15 14 15 15 15 15 15 15 15 15
    ArrayList(SZ) 33.20/7.21: 26 41 26 40 26 41 26 40 26 40
    HashSet(SZ) 520.30/1.73: 523 519 520 518 519 521 519 523 522 519
    LinkedList() 345.90/31.44: 336 339 332 336 440 336 334 337 332 337
    If the initial capacity is set Vector was a clear winner for collectons of this size.
    Edited by: pbrockway2 on Jan 10, 2008 11:16 AM
    I have no fscking idea why Vector should appear to get slower when the initial size is set to 10K. But, there you are.

  • EVA performance with ESXi 5.1

    We are having problems with some of our Linux VMs going read only and Windows VMs slowing right down on our P6000 EVA. The problem tends to appear during a backup window, but sometimes during the working day under heavy periods of activity. It seems to be storage performance related. ESXi 5.1 is using round robin and there are no network issues.
    Has anyone tried these advanced ESXi settings which are reported to improve performance?
    (From: http://arritdor.e-wilkin.com/2012/05/vmware-esxi-and-hp-3par-storage.html)
    DiskMaxIOSize   = 128
    QFullSampleSize = 32  
    QFullThreshold  = 4

    I think it might be beneficial to take a look at the array performance statistics. The evaperf can be found at c:\Program Files\Hewlett-Packard\EVA Performance Monitor if it is selected during CommandView installation. Some useful stats to collect are:
    evaperf cs –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > controller.csv
    evaperf hps –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > hostport.csv
    evaperf vd –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > vdisk.csv
    evaperf pdg –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > diskgroup.csv
    evaperf pda –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > disk.csv
    where xxxx-xxxx-xxxx-xxxx is the world wide name of the array e.g. 5000–1FE1–5000–A9F0. You can probably find it on the controller LCD or some serial number label sticker at the back.
    Because window server command prompt does not support running command at the background (at least I do not know how) unlike hp-ux server, you will have to open several command prompt window and run these command at the same time. Then probably zip and posted it somewhere so that we can all take a look.
    the 60 here means we make one collection every 60 seconds, and -dur 3600 means for a duration of 3600 seconds which is one hour. For a start, we do not want to collect huge amount of data. We probably want to collect one set when array has no problem, and one set when array has problem, then make a comparison.

  • Xserve-RAID array intialising

    An established array on my RAID has sudddenly begun the intilising process. Is this normal? Why would it be doing this now - it was initialised when I set it up so why now?
    Also - why does the initialising proces take so incredibly long?!

    Initializing? that sounds like a problem. Unless you mean either scrubbing/conditioning or rebuilding.
    The former can be initiated via RAID Admin, and makes the XServe RAID check every block on the disk.
    The latter may happen if a disk fails and the data needs to be replicated/rebuilt on a spare drive.
    Initializing, as its name implies, involves setting up an new array. This doesn't usually (ever?) happen on its own, but only at the behest of someone using RAID Admin to manipulate the array.
    As for the duration - if you're using RAID 5, creating the array performs a scrub of each disk to verify its integrity, as well as creating the initial parity data. If you enable the background option, the array is available for use immediately, even while the scrub is progressing.

  • ZFS and StorageTek 6140 performance

    We have a Sun StorageTek 6140 Disk array and currently two Solaris 10 x86 hosts connected to it via Fibre channel through a Qlogic 5602 FC Switch.
    One system is our production E-mail system (Running Sun Messaging) the other is a backup server.
    The backup server is running CAM software an periodically issues a snapshot to be done on the 6140. I have noticed that copying or taring up files on either the production volume or the snapshot volume has very poor performance.
    Basically between 2-4MB/s
    We have patched the kernel 5.10 Generic_127128-11 i86pc i386 i86pc and tried various settings in /etc/system
    set zfs:zfs_prefetch_disable=1
    set zfs:zfs_nocacheflush=1
    But still the performance is not improving. The array seems to function properly (that is if I use "dd" then the array performs quickly so I must believe that it has something to do with ZFS).
    Has anyone else had issues with ZFS performance on a 6140 array or similar? What kind of speeds are you seeing with actual file system usage?
    I should also add that If I used a UFS formatted filesystem on the array I saw cp/tar speeds around 10-12MB/s
    thanks,
    -Tomas

    Hello Nik,
    Fortunately I have generated supportdata package before upgrading and CAM version is 6.7.0.12. In addition to your reply I found an article at http://www.tune-it.ru/web/bender/blogs/-/blogs/восстановление-томов-на-массивах-6000-и-2000-серии , for not-russian speakers: the article provides the similar solution with /opt/SUNWsefms/bin/service utility, but the author made a note about an offset=<blocks> field, he multiplies the value from profile by 512, I had some volumes being stored on a single Vdisk, and I'm not sure now, because in your's and author's service utulity template it was clearly marked that the value of an argument is in blocks, and the stored in profile value is also in blocks (not in bytes, the piece of my profile - "+...GB (598923542528 bytes) Offset (blocks): ...+"), is he right by multiplying the value from profile?
    - Second question - does a service utility provide a functionality to change wwn's on volumes and Storage array identifier (SAID) at whole device? I found out that the previous license files are not accepted, because of another Feature Enable Identifier (I think it is calculated from a changed value of Storage array identifier, am I right?), and why I want to change the wwn's and mappings (mappings will correct from the bui) on recreated volumes as per profile is is that I want to avoid problems by possible misrecognition them by vxvm at a server side (target numbering change) and further recorrecting/reimporting vxvm disks and disk group ownership.

  • EVA 4400 disk performanc​e

    Hi
    We're running HP blade system on Hyper-V 2008 R2 cluster with EVA 4400 storage.
    EVA has two disk groups
    - diskgroup 0 (enclosuer 0) with 10 FC disks 400GB 10k
    - diskgroup 1 (enclosure 1) with 8 FC disks 300GB 15k
    We're dealing with a high impact on disk I/O performance on SQL servers running on Hyper-V hosts on VM (Win2008 + SQL 2008). 
    R/W performance is between 20-30MB/s, but only on servers running SQL. On all other VM servers without SQL performance is between 50-60MB/s.
    We have already consulted with Microsoft support, they didn't find any issues with cluster or VM, also there is no other HW impact on performance. 
    The only conclusion by our appinion is that SQL servers are generating so many I/O requests, that EVA or HBA on hosts can't handle that.
    Is this true, or how can we check that ? SQL profiler show normal activity, also there is no other issues with operating sistem, so we're certain that there must be some kidn of connection between VM - HOST - EVA.
    Also running RW test directly on a host connected to EVA, Read results are between 200-300MB/s, but Write is between 60-100MB/s.
    Any additional points how to proceed next are welcome.
    Regards,
    Miha

    I think it might be beneficial to take a look at the array performance statistics. The evaperf can be found at c:\Program Files\Hewlett-Packard\EVA Performance Monitor if it is selected during CommandView installation. Some useful stats to collect are:
    evaperf cs –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > controller.csv
    evaperf hps –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > hostport.csv
    evaperf vd –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > vdisk.csv
    evaperf pdg –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > diskgroup.csv
    evaperf pda –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > disk.csv
    evaperf vdg –cont 60 -dur 3600 -csv -ts2 -sz xxxx-xxxx-xxxx-xxxx > vdiskgroup.csv
    where xxxx-xxxx-xxxx-xxxx is the world wide name of the array e.g. 5000–1FE1–5000–A9F0. You can probably find it on the controller LCD or some serial number label sticker at the back.
    Because window server command prompt does not support running command at the background (at least I do not know how) unlike hp-ux server, you will have to open several command prompt window and run these command at the same time. Then probably zip and posted it somewhere so that we can all take a look.
    the 60 here means we make one collection every 60 seconds, and -dur 3600 means for a duration of 3600 seconds which is one hour. For a start, we do not want to collect huge amount of data. We probably want to collect one set when array has no problem, and one set when array has problem, then make a comparison

  • Storing Uploaded Image Path into Mysql

    Hi I am developing a cms and am using the code David gives in his book PHP Solutions,  everything works fine but I can't work out how to extract the uploaded path so that it is stored in my table.
    Help would be really appreciated, I am making good progress in learning the php especially with David's books but am still struggling when it comes to having to customized the code.
    The code for the upload.php is as follows,
    <?php
    class Gp1_Upload{
      protected $_uploaded = array();
      protected $_destination;
      protected $_max = 51200;
      protected $_messages = array();
      protected $_permitted = array('image/gif',
                                    'image/jpeg',
                                    'image/pjpeg',
                                    'image/png');
      protected $_renamed = false;
      public function __construct($path) {
        if (!is_dir($path) || !is_writable($path)) {
          throw new Exception("$path must be a valid, writable directory.");
        $this->_destination = $path;
        $this->_uploaded = $_FILES;
      public function getuploadpath (){
      public function getMaxSize() {
        return number_format($this->_max/1024, 1) . 'kB';
      public function setMaxSize($num) {
        if (!is_numeric($num)) {
          throw new Exception("Maximum size must be a number.");
        $this->_max = (int) $num;
      public function move($overwrite = false) {
        $field = current($this->_uploaded);
        if (is_array($field['name'])) {
          foreach ($field['name'] as $number => $filename) {
            // process multiple upload
            $this->_renamed = false;
            $this->processFile($filename, $field['error'][$number], $field['size'][$number], $field['type'][$number], $field['tmp_name'][$number], $overwrite);   
        } else {
          $this->processFile($field['name'], $field['error'], $field['size'], $field['type'], $field['tmp_name'], $overwrite);
      public function getMessages() {
        return $this->_messages;
      protected function checkError($filename, $error) {
        switch ($error) {
          case 0:
            return true;
          case 1:
          case 2:
            $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
            return true;
          case 3:
            $this->_messages[] = "Error uploading $filename. Please try again.";
            return false;
          case 4:
            $this->_messages[] = 'No file selected.';
            return false;
          default:
            $this->_messages[] = "System error uploading $filename. Contact webmaster.";
            return false;
      protected function checkSize($filename, $size) {
        if ($size == 0) {
          return false;
        } elseif ($size > $this->_max) {
          $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
          return false;
        } else {
          return true;
      protected function checkType($filename, $type) {
        if (empty($type)) {
          return false;
        } elseif (!in_array($type, $this->_permitted)) {
          $this->_messages[] = "$filename is not a permitted type of file.";
          return false;
        } else {
          return true;
      public function addPermittedTypes($types) {
        $types = (array) $types;
        $this->isValidMime($types);
        $this->_permitted = array_merge($this->_permitted, $types);
      protected function isValidMime($types) {
        $alsoValid = array('image/tiff',
                           'application/pdf',
                           'text/plain',
                           'text/rtf');
          $valid = array_merge($this->_permitted, $alsoValid);
        foreach ($types as $type) {
          if (!in_array($type, $valid)) {
            throw new Exception("$type is not a permitted MIME type");
      protected function checkName($name, $overwrite) {
        $nospaces = str_replace(' ', '_', $name);
        if ($nospaces != $name) {
          $this->_renamed = true;
        if (!$overwrite) {
          $existing = scandir($this->_destination);
          if (in_array($nospaces, $existing)) {
            $dot = strrpos($nospaces, '.');
            if ($dot) {
              $base = substr($nospaces, 0, $dot);
              $extension = substr($nospaces, $dot);
            } else {
              $base = $nospaces;
              $extension = '';
            $i = 1;
            do {
              $nospaces = $base . '_' . $i++ . $extension;
            } while (in_array($nospaces, $existing));
            $this->_renamed = true;
        return $nospaces;
      protected function processFile($filename, $error, $size, $type, $tmp_name, $overwrite) {
        $OK = $this->checkError($filename, $error);
        if ($OK) {
          $sizeOK = $this->checkSize($filename, $size);
          $typeOK = $this->checkType($filename, $type);
          if ($sizeOK && $typeOK) {
            $name = $this->checkName($filename, $overwrite);
            $success = move_uploaded_file($tmp_name, $this->_destination . $name);
            if ($success) {
                $message = "$filename uploaded successfully";
                if ($this->_renamed) {
                  $message .= " and renamed $name";
                $this->_messages[] = $message;
            } else {
              $this->_messages[] = "Could not upload $filename";
    ?>
    The code for my form page is this
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    //THE FOLLOWING CODE IS FOR THE UPLOADING OF IMAGES AND FILES
    // set the max upload size in bytes
    $max = 51200;
    if (isset ($_POST ['submit']))
                //define the path to the upload folder
                $destination = 'uploads/';
                require_once('classes/Upload.php');
                try {
                    $upload = new Gp1_Upload($destination);
                    $upload->setMaxSize($max);
                    $upload->move();
                    $result = $upload->getMessages();
                } catch (Exception $e) {
                    echo $e->getMessage();
    // END OF UPLOADING OF IMAGES AND FILES
    ?>
    <form id="newvenue" action="" method="post" enctype="multipart/form-data" >
          <?php
               // THIS CODE DISPLAYS ERROR MESSAGES FOR THE FILE UPLOADS
              if (isset($result)){
              echo '<ul>';
              foreach ($result as $message){
                  echo "<li>$message</li>";
              echo '</ul>';
           ?>
      <table id="neweventdisplay" cellpadding="5"  border="0">
        <tr>
      <td></td>
      <td><input type="hidden" name="user_id"  value="" /></td>
      </tr>
      <tr>
      <td></td>
        <td>Organisers Name</td>
        <td><input class="input80px" id="org_name" name="org_name" type="text" /> </td>
      </tr>
      <tr>
      <td></td>
      <td><label for="image">Upload image:</label></td>
      <td><p>
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>" />
    <input type="file" name="image" id="image" />
    </p></td>
    </tr>
      <tr>
      <td></td>
      <td>Details about your upload</td>
      <td><input class="input80px" id="org_uploadcapt" name="org_uploadcapt" type="text"  /></td>
    </tr>
      <tr>
      <td></td>
      <td><input type="submit" name="submit" id="submit" value="upload"></td>
      </tr>
      <tr>
      <td class="heading"> </td>
      <td></td>
      </tr>
    </table>
    </form>
    <prep>
    <?php
    if (isset ($_POST ['submit'])){
        print_r($_FILES);}
        ?>
        </prep>
    </body>
    </html>

    Hi David
    Thank you very much for your help.  I had continued to work on the code and had worked out how to input the image path into the database but it was using the original filename, so when every it is changed it did not work.  The code in my page at that point was the following,
    <?php     // 2. NEW USER REGISTRATION<br />
            include_once ("includes/form_functions.inc.php");
            $max = 100000;
            $destination = 'uploads/';
            // START FORM PROCESSING FOR A NEW REGISTRATION
            if (isset($_POST['submit'])) { // Form has been submitted.
            $errors = array();
            // perform validations on the form data
            $required_fields = array('org_name');
            $errors = array_merge($errors, check_required_fields($required_fields, $_POST));    
            $required_numberfields = array('user_id');
            $errors = array_merge($errors, check_number_fields($required_numberfields, $_POST));
            $fields_with_lengths = array('org_name' => 36, 'org_website' => 100, 'org_contact' => 40,  'org_conemail' => 80, 'org_contel' => 30);
            $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST));
            /*Here I am using trim as well as ucwords, this function converts the first letter of each work into a capital letter,  I am using this only on the
            firstname and surname to ensure that the data is how I want it as it is going  into the database,  The better the data is preformated the better the data
            swill be within the database.*/
            $org_name = trim(strtolower(mysql_prep($_POST['org_name'])));
            $org_website = trim(strtolower(mysql_prep($_POST['org_website'])));
            $org_contact = trim(strtolower (mysql_prep($_POST['org_contact'])));
            $org_conemail = trim(strtolower (mysql_prep($_POST['org_conemail'])));
            $org_contel = strtolower (mysql_prep($_POST['org_contel']));
            $userid = $_POST['user_id'];
            $org_uploadcapt = $_POST['org_uploadcapt'];
            $image = $_FILES['image'];
            /*Here is the code that takes the variable captured from the input form and matches it  up with the appropriate field in the database.  An important point with insertion is that  the variables are in the same order as the mysql field names, there will be an error if the number of variables does not match the number of field names.  Note that there is no entry for the user id as this is an auto increment file within mysql and so is not needed to be entered*/
            if ( empty($errors) ) {
                $sql = "INSERT INTO organiser
                          (org_name, org_website, org_contact, org_conemail, org_contel, user_id, org_uploadurl, org_uploadcapt)
                          VALUES
                          ('{$org_name}', '{$org_website}', '{$org_contact}', '{$org_conemail}', '{$org_contel}', '{$userid}', '{$destination}".$image['name']."', '{$org_uploadcapt}' )";
                $result = mysql_query($sql, $connection);
                if ($result) {
                    $message = "The organiser was successfully created.<br />";
                } else {
                    $message = "I am sorry but the organiser could not be added.";
                    $message .= "<br />" . mysql_error();
                } else {
                    /* this counts the number of errors and informs the user of how many fields were
                    incorrectly entered*/
                if (count($errors) == 1) {
                    $message = "There was 1 error in the form.";
                } else {
                    $message = "There were " . count($errors) . " errors in the form.";
        } else { // Form has not been submitted.
            $org_name = "";
            $org_website = "";
            $org_contact = "";
            $org_conemail = "";
            $org_contel = "";
            $userid = "";
            $org_uploadcapt = "";
    //THE FOLLOWING CODE IS FOR THE UPLOADING OF IMAGES AND FILES
    // set the max upload size in bytes
    if (isset ($_POST ['submit']))
                //define the path to the upload folder
                // Use This On The Local Hosting Machine
                //$destination = 'C:/upload_test/';
                // Use This On The Live Server
                require_once('classes/Upload.php');
                try {
                    $upload = new Gp1_Upload($destination);
                    $upload->setMaxSize($max);
                    $upload->move();
                    $result = $upload->getMessages();
                } catch (Exception $e) {
                    echo $e->getMessage();
    // END OF UPLOADING OF IMAGES AND FILES
    ?>
    <title>Horse Events</title>
    <?php include_once("includes/meta.inc.php");?>
    <?php include_once("includes/cssfavgoogle.inc.php");?>
    <link href="css/adminpanel.css" rel="stylesheet" type="text/css" />
    <style>
    input[type="number"] {
        width:40px;
    </style>
    </head>
    <body>
    <div id="wrapper">
        <div id="admincontent">
    <form id="newvenue" action="neworganiser.php" method="post" enctype="multipart/form-data" >
          <?php if (!empty ($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
          <?php if (!empty ($errors)) {display_errors($errors); } ?>
          <?php
              // THIS CODE DISPLAYS ERROR MESSAGES FOR THE FILE UPLOADS
              if (isset($result)){
              echo '<ul>';
              foreach ($result as $message){
                  echo "<li>$message</li>";
              echo '</ul>';
           ?>
    <br />
          <table id="neweventdisplay" cellpadding="5"  border="0">
        <tr>
      <td></td>
      <td><input type="hidden" name="user_id"  value="<?php echo $url_userid ['user_id']; ?>" /></td>
      </tr>
      <tr>
      <td> <span class="compuls">*</span></td>
        <td>Organisers Name</td>
        <td><input class="input80px" id="org_name" name="org_name" type="text" />
         </td>
      </tr>
          <tr>
          <td><span class="compuls">*</span></td>
        <td>Their Website</td>
        <td><input class="input80px" id="org_website" name="org_website" type="text" /></td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
        <td>Organisers Contact</td>
        <td><input id="org_contact" name="org_contact" type="text" />eg: Mrs Jean Kelly</td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
        <td>Contact Email</td>
        <td><input class="input80px" id="org_conemail" name="org_conemail" type="text" />
          </td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
      <td>Contact Tel No.</td>
      <td><input id="org_contel" name="org_contel" type="text" /></td>
      </tr>
      <tr>
      <td></td>
      <td><label for="image">Upload image:</label></td>
      <td><p>
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>" />
    <input type="file" name="image" id="image" />
    </p></td>
    </tr>
      <tr>
      <td></td>
      <td>Details about your upload</td>
      <td><input class="input80px" id="org_uploadcapt" name="org_uploadcapt" type="text"  /></td>
    </tr>
      <tr>
      <td></td>
      <td><input type="submit" name="submit" id="submit" value="Add Your Organiser"></td>
      </tr>
      <tr>
      <td class="heading"> </td>
      <td></td>
      </tr>
    </table>
    <a  class="delete" href="controlpanel.php">Cancel</a>
    </form>
        </div>
    I have added the code you kindly forwarded but am getting an error,  I am still trying to learn the basics of php and am unsure of what to do next, my php Upload.php now looks like
    <?php
    class Gp1_Upload{
      protected $_uploaded = array();
      protected $_destination;
      protected $_max = 100000;
      protected $_messages = array();
      protected $_permitted = array('image/gif',
                                    'image/jpeg',
                                    'image/pjpeg',
                                    'image/png');
      protected $_renamed = false;
      protected $_filenames = array();
      public function __construct($path) {
        if (!is_dir($path) || !is_writable($path)) {
          throw new Exception("$path must be a valid, writable directory.");
        $this->_destination = $path;
        $this->_uploaded = $_FILES;
      public function getMaxSize() {
        return number_format($this->_max/100000, 1) . 'kB';
      public function setMaxSize($num) {
        if (!is_numeric($num)) {
          throw new Exception("Maximum size must be a number.");
        $this->_max = (int) $num;
      public function move($overwrite = false) {
        $field = current($this->_uploaded);
        if (is_array($field['name'])) {
          foreach ($field['name'] as $number => $filename) {
            // process multiple upload
            $this->_renamed = false;
            $this->processFile($filename, $field['error'][$number], $field['size'][$number], $field['type'][$number], $field['tmp_name'][$number], $overwrite);   
        } else {
          $this->processFile($field['name'], $field['error'], $field['size'], $field['type'], $field['tmp_name'], $overwrite);
      public function getMessages() {
        return $this->_messages;
      protected function checkError($filename, $error) {
        switch ($error) {
          case 0:
            return true;
          case 1:
          case 2:
            $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
            return true;
          case 3:
            $this->_messages[] = "Error uploading $filename. Please try again.";
            return false;
          case 4:
            $this->_messages[] = 'No file selected.';
            return false;
          default:
            $this->_messages[] = "System error uploading $filename. Contact webmaster.";
            return false;
      protected function checkSize($filename, $size) {
        if ($size == 0) {
          return false;
        } elseif ($size > $this->_max) {
          $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
          return false;
        } else {
          return true;
      protected function checkType($filename, $type) {
        if (empty($type)) {
          return false;
        } elseif (!in_array($type, $this->_permitted)) {
          $this->_messages[] = "$filename is not a permitted type of file.";
          return false;
        } else {
          return true;
      public function addPermittedTypes($types) {
        $types = (array) $types;
        $this->isValidMime($types);
        $this->_permitted = array_merge($this->_permitted, $types);
      protected function isValidMime($types) {
        $alsoValid = array('image/tiff',
                           'application/pdf',
                           'text/plain',
                           'text/rtf');
          $valid = array_merge($this->_permitted, $alsoValid);
        foreach ($types as $type) {
          if (!in_array($type, $valid)) {
            throw new Exception("$type is not a permitted MIME type");
      protected function checkName($name, $overwrite) {
        $nospaces = str_replace(' ', '_', $name);
        if ($nospaces != $name) {
          $this->_renamed = true;
        if (!$overwrite) {
          $existing = scandir($this->_destination);
          if (in_array($nospaces, $existing)) {
            $dot = strrpos($nospaces, '.');
            if ($dot) {
              $base = substr($nospaces, 0, $dot);
              $extension = substr($nospaces, $dot);
            } else {
              $base = $nospaces;
              $extension = '';
            $i = 1;
            do {
              $nospaces = $base . '_' . $i++ . $extension;
            } while (in_array($nospaces, $existing));
            $this->_renamed = true;
        return $nospaces;
      protected function processFile($filename, $error, $size, $type, $tmp_name, $overwrite) {
        $OK = $this->checkError($filename, $error);
        if ($OK) {
          $sizeOK = $this->checkSize($filename, $size);
          $typeOK = $this->checkType($filename, $type);
          if ($sizeOK && $typeOK) {
            $name = $this->checkName($filename, $overwrite);
            $success = move_uploaded_file($tmp_name, $this->_destination . $name);
            if ($success) {
                $message = "$filename uploaded successfully";
                if ($this->_renamed) {
                  $message .= " and renamed $name";
                $this->_messages[] = $message;
            } else {
              $this->_messages[] = "Could not upload $filename";
      public getFilenames() {
        return $this->_filenames;
    ?>
    The error is Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE.   
    I have not worked with oop before and have only very briefly looked at the principle was on my foundation degree.

  • Embedded LV 8.0 Real-Time application on cFP-2120

    Hi!
    I'm working on a project which involves programming of a real-time application running on a cFP-2120. The purpose of the application is to control the motion over 7 test-objects with a servomotor.  Test-objects have 3 sensors each. Remote control of the application is necessary. The program should have a GUI which shows graphics of sensordata and buttons to open other VIs like set-up, details, logging etc.
    Could i just build an application like it was meant to run on a pc, deploy it to the cFP-2120 and use Connect to Remote Panel ?
    Or
    Should I build separate VIs;
    -the program which always runs on the cFP-2120 and
    -the User Interface which is runned on a computer now and then which gets value from Network-Published shared Variables
    I need some tips here 

    I would definitely go for the second option, esp. if you want to have this program for a longer time.
    It's much easier to write a good GUI on the PC without the limitations of a real time OS. There you have to keep too many things in mind (esp. no dynamic arrays, performance issues due to GUI programming, not too many sub VIs)... So write a quite minimal control software for FP and do all the interface stuff on the PC. Then you can easily log all the data into a database (if you have the DSC Engine) as well.
    Cheers,
      Carsten

  • New computer core I7 950

    Hi!
    I am just going to config. a new computer for editing HD and AVCHD videos. I bought a new videocamera, a Canon Legria HF 200 recently, and it`s not possible to edit HD and AVCHD on my old computers. I am planning to run Win.7 64 bit and Prem.El.8+Photoshop El.8. Is there anyone that can tell me if this is a good config. for my purpose? I also have some qustions
    about setting up my 4 Samsung Spinpoints. I have tried to read as much as possible but my english is not so good and I am just an computeramateur so there are som things I don`t understand. Sometimes people says "editing" and sometimes they say "rendering", is this the same? Then I don`t know if I should use Raid or singel disks. If Raid, Raid 0 on 2 disks or Raid 5 on all 4 disks,(not the ssd). For safe I will have an ext.disk for backup. Is this a good setup?
    1 SSD:OS and programs.
    1 Spinp.:Pagefile, scratch and rendering,(editing?).
    1 Spinp.:Media.
    1 Spinp.:Projects.
    1 Spinp.: Final results.
       1  CPU:Intel Core i7 950 3,06GHz
       2  Mem:OCZ Gold Triple Channel 6GB Kit 3x2GB DD =12 GB
       1  MOBO: ASUS P6T SE -ATX LGA     
       1  Desktop:Logitech Pro 2400 Cordless Desktop
       1  BenQ M2200HD 22" LCD
       4  HDD: Samsung Spinpoint F1 1TB SATA 3.0 G for ?
       1  DVD combo:Samsung SH-S223B/BEBE DVDRW 22X Black
       1  Ext. HDD:Western Digital MyBook Essential 1TB USB for backup
       1  Power:Zalman ZM850-HP, 850W ATX
       1  HDD:OCZ Agility 60GB 2.5" SSD SATA II  (for OS and progr).
       1 Graf. Sapphire Radeon HD5850 1GB GDDR5
       1 Chassi Cooler Master HAF 932 ATX
       1 CPU cooler: Coolermaster Hyper 212 Plus ( for future OC)
       Hope you understand my English.
       From Åland Islands

    I gave you my opinion on Raid 0 in my above post.
    Regarding Raid 5, it is really a matter of personal preference. If you are good at doing regular backups of data, and at least one timely backup of a complete Drive Image, then Raid 5 might not be your cup of tea.
    Here is some additional technical details on a Raid 5 configuration from Intel Tech Support:
    (One key statement below is that Raid 5 performs better with small I/O files, (versus the large data files associated with video). ~~ And you'll need to tie up a minimum of 3 hard drives to accomplish this sense of data recovery and availability)...
    RAID 5 (STRIPING WITH PARITY)
    RAID level 5 combines three or more hard drives so that all data is divided into manageable blocks called strips. RAID 5 uses parity, which is a mathematical method for recreating lost data to a single drive, which increases fault tolerance. The data and parity are striped across the array members in a rotating sequence. Because of the parity striping, it is possible to rebuild the data after replacing a failed hard drive with a new drive. The extra work of calculating the missing data will degrade the write performance to the volumes while data is being rebuilt. RAID 5 performs better for smaller I/O functions than larger sequential files.
    Advantages: Full data redundancy; efficient; fault-tolerant and increased storage array performance.
    Disadvantage: Time consuming to rebuild and decreased performance during rebuilding.
    Applications: Good choice for file and application servers; Internet and Intranet servers.

  • LSI Megaraid 9260/9261 driver issue on Solaris x86-64

    We have several x4170 M2 machines with either the LSI 9260 or 9261 megaraid cards (same driver) where SUN uses the "SUNWmr_sas" driver, and you can download the latest driver from LSI website as "mr_sas". Using SUN Solaris 10 update 9 with latestl patches, x86 64-bit version .
    Created two RAID arrays in the card BIOS (RAID1 using 2 disks and a RAID5 using 6 disks). Each disk is a 146GB 10k RPM SAS drive. The firmware on the card is the latest version from April 2011.
    A copy from the RAID1 array to the RAID5 array yields a measly 5MB/s transfer speed. Tried both drivers with the same result. Tried all sorts of RAID array settings with no luck.
    Installed Ubuntu Linux 10.04 LTS 64-bit version without touching the RAID array settings and the transfer speed jumped to over 100 MB/s (expected results).
    Network copies to a single array and local copies within a single array perform as expected. Only the copy from one array to the other seems to be effected.
    This leads me to believe the LSI driver for Solaris is at fault. Any thoughts? Anyone else noticing this poor performance?

    Hi.
    Read thread:
    X4x70 (M1) with extremely slow disk I/O
    Try workaround the problem by adding the following line to /etc/system and then reboot:
    set idle_cpu_no_deep_c = 1
    Regards.

  • JSF - How To align one element of a gridpanel

    The following is the code. What i need is to right align the label at the left side. ie
    Name TextField
    Age TextField
    Address TextArea
    Now how i had achived is to put th outputlabel inside another gridpanel and give its alignment as right. Please see the code of "*Name*" label
    <center><h:panelGrid border="0" columns="2"
                   style="width: 540px">
                            <h:panelGrid styleClass="number" columns="1" style="width: 138px">
                          <h:outputLabel value="Name"></h:outputLabel>
                         </h:panelGrid>
                   <h:inputText id="employeeId" value="#{employee.employeeName}"
                        style="width: 355px"></h:inputText>
                        <h:outputLabel value="Code"></h:outputLabel>
                   <h:inputText id="employeeCode" value="#{employee.employeeCode}"
                        style="width: 162px"></h:inputText>
                        <h:outputLabel value="Age"></h:outputLabel>
                   <h:inputText id="ageId" value="#{employee.age}" style="width: 69px"></h:inputText>
                        <h:outputLabel value="Addtess"></h:outputLabel>
                   <h:inputTextarea id="addressId" value="#{employee.address}"
                        style="height: 108px; width: 360px"></h:inputTextarea>
                        <h:outputLabel value="Identification Mark 1"></h:outputLabel>
                   <h:inputText id="identification1"
                        value="#{employee.identificationFirst}" style="width: 368px"></h:inputText>
                        <h:outputLabel value="Identification Mark 2"></h:outputLabel>
                   <h:inputText id="identification2"
                        value="#{employee.identificationSecond}" style="width: 368px"></h:inputText>
                        <h:outputLabel value="Designation"></h:outputLabel>
                   <h:selectOneMenu value="#{employee.designationId}">
                        <f:selectItems value="#{designation.designationList}" />
                   </h:selectOneMenu>
         </h:panelGrid></center>

    Index out the element you want to modify (using index array), perform the modification, put back at right index using replace array element.
    If you are worried about performance, use the in-place element.
    http://www.ni.com/white-paper/6211/en/
    CLA
    www.dvel.se

Maybe you are looking for

  • Delta Records not coming from sm13 to rsa7

    Hi, We have found that for the application 02, delta records are coming in RSA7(delta queue) even if these are coming in sm13. It appears that some protocol responsible for bringing the delta records from sm13 to rsa7 is failed. Fact is that for the

  • Need help with an Aforge and windows forms memory stack-up issue

    Hello, I am experiencing a strange memory stack-up in my c# windows form program that occurs all the time on slow PCs, and when the windows form loses focus or is otherwise interrupted on faster PCs. The program I have written uses Aforge to get imag

  • Esata to mac mini

    Is there any way I can connect my eSATA external drives to my Mac mini (new 2011 model)? Third-party hardware adaptors maybe? Cheers!

  • IPad stolen. Can I see what app data was backed up in iCloud?

    Hello, My ipad was stolen. How can I see what app data was backed up on icloud? Thank you - Jim

  • Getting back to vanilla Safari state

    I am running 4.0.1 (5530.18) of Safari. When I load Safari it takes a few seconds for the page to display. I think I may have some Safari plugins I would like to get rid as well as putting Safari back to it's original state. How can I do this?