Help with arrays in PHP

Hi All,
I have created a page that shows thumbnail images of all
images in a
given directory. Here is the function that searches the
directory and
builds an array of qualified files:
> function getImages($dir) {
> $directory = new DirectoryIterator($dir);
> $fileTypes =
'#\.jpg$|\.jpeg$|\.gif$|\.png$|\.JPG$|\.GIF$|\.PNG$#i';
> $filtered = new RegexIterator($directory, $fileTypes);
> $array = array();
> foreach ($filtered as $item) {
> $array[] = $item->getFilename();
> }
> return new ArrayIterator($array);
> }
>
> // get an ArrayIterator of filenames and the total
number:
> $images = getImages('../images/images_news/');
> $totalImages = $images->count();
Here is the HTML and PHP used to display the images (I'm
excluding code
that is specific to the paging function):
> // Implement offset and files per page
> foreach (new LimitIterator($images, $offset,
$filesperpage) as
> $image) { ?>
> <div class="imgcont">
> <div class="imgholder">
> <img src="../images/images_news/<?php echo $image;
?>"
> alt="<?php echo $image; ?>" height="55"
class="center" />
> </div>
> <p class="smallname"><?php echo $image;
?></p><br />
> </div>
> <?php } ?>
> <div class="clear"><br />
My question is this. I need to provide a way to delete images
that will
no longer be needed. Actually, I need to be able to delete
the main
image and the thumbnail image, each of which is in a separate
directory. What I don't know is how this type of thing is
normally done
(I don't want the FTP route because I don't want a client
messing about
in the directory structure). And what I don't understand is
how to
select one or more files to delete when they were produced by
an array.
For ease of use, it would be nice if I could add a checkbox
that the
user could check to indicate that the image(s) should be
deleted. I
just can't figure out how to select the file(s). I sure hope
this is
not one of those simple things that will make me hide my head
in shame.
Any help would be most appreciated.
Brett

Brett wrote:
> the thumbnail images now have _tmb inserted between
> the file name and the extension. So when deleting I keep
getting
> warnings that the file mypic001.jpg cannot be found in
the thumbs
> directory. How do I get the _tmb into the file name?
foreach ($_POST['images'] as $image) {
unlink($mainImgDir . $image);
$pos = strrpos($image, '.');
$thumb = substr($image, 0, $pos) . '_tmb' . substr($image,
$pos);
unlink($thumbsDir . $thumb);
> By the way, you used unset() where I think you meant
unlink().
Yes, I did. Sorry about that.
> Finally, I have discovered that if I upload a file named
Ti301.JPG, I
> get Ti301.JPG001_thb.jpg. It seems that the strtolower()
function in
> getNextFilename5.php is not converting the uppercase
extension, it is
> just adding the incremented number plus _tmb and the new
extension. Any
> ideas about how to correct that?
That shouldn't be happening, but I don't have time to look
into that
now. Sorry.
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Similar Messages

  • Need Urgent Help with Apache and PHP

    I have been struggling with apache and php for a week now and I finally broke down to post a message.
    I have apache 1.3 running on my mac mini g4 with 10.4.9 and I installed sql. I went to the entropy website and downloaded php5 to install without knowing I already had php4 on the machine. I installed 5 but could not get it to work. I then went back to httpd.conf and tried to install php4 by uncommenting out the loadmodule and addmodule lines. I restarted apache but php still did not work. I tested the phpinfo.php script but all I got was the script in Safari and not the actual page. At the moment, I have php4 and php5 on my machine but can't get either one to work. I am sure there is an easy fix but I don't know it. Please help.

    The problem is not terribly complicated, but Apache will not start with the entropy file in the folder
    /etc/httpd/users/
    Let me experiment on you. Rename the entropy file and then try to start Apache. To do this, open Terminal and paste this command:
    <pre>sudo mv /etc/httpd/users/+entropy.conf /etc/httpd/users/+entropy<pre>
    Now check the Apache configuration:
    <pre>apachectl configtest<pre>
    If it says "Syntax OK", start Apache:
    <pre>sudo apachectl start<pre>
    Since we only disabled the entropy file, you should be able to enable PHP5 with some more advanced configuring.

  • Need help with Arrays

    Hey guys, I'm a beginner programmer and I'm having a bit of a tough time with arrays. I could really use some help!
    What I'm trying to do is roll one die and then record the rolls.
    Here is my sample I/O:
    How many times should I roll a die?
    -> 8
    rolling 8 times
    2, 1, 5, 6, 2, 3, 6, 5
    number of 1's: 1
    number of 2's: 2
    and so on....
    Here is my incomplete code at this moment:
    //CountDieFaces.java
    import java.util.Scanner;
    import java.io.*;
    import library.Gamble;
    public class CountDieFaces
        //prompt for and read in: number of times user wants to roll one die
        //simulate rolling a die that many times, counting how many times each face 1 thru 6 comes up
        //print out: each roll
        //AND the total number of times each face occured and the percentage of the time each face occured.
        Scanner scan = new Scanner(System.in);
        int[] faceCount= {0,0,0,0,0,0,0};
        int dice;
        System.out.println("How many times would you like to roll the die?");
        int dieCount = scan.nextInt();
        int dieRoll = Gamble.rollDie(); // Main calling class method
        int count = 1;
        while(count < dieCount)
            System.out.println(faceCount[count]);
            count++;
    }Here is the gamble library:
    //Gamble.java
    package library;
    public class Gamble
         // returns 1, 2, 3, 4, 5, or 6
         public static int rollDie()
              int dieRoll = (int)(Math.random()*6)+1;
              return dieRoll;
    }and here are the errors I have so far:
    ----jGRASP exec: javac -g CountDieFaces.java
    CountDieFaces.java:19: <identifier> expected
         System.out.println("How many times would you like to roll the die?");
         ^
    CountDieFaces.java:19: illegal start of type
         System.out.println("How many times would you like to roll the die?");
         ^
    CountDieFaces.java:25: illegal start of type
         while(count < dieCount)
         ^
    CountDieFaces.java:25: > expected
         while(count < dieCount)
         ^
    CountDieFaces.java:25: ')' expected
         while(count < dieCount)
         ^
    CountDieFaces.java:26: ';' expected
         ^
    CountDieFaces.java:27: illegal start of type
              System.out.println(faceCount[count]);
              ^
    CountDieFaces.java:27: ';' expected
              System.out.println(faceCount[count]);
              ^
    CountDieFaces.java:27: invalid method declaration; return type required
              System.out.println(faceCount[count]);
              ^
    CountDieFaces.java:27: ']' expected
              System.out.println(faceCount[count]);
              ^
    CountDieFaces.java:27: ')' expected
              System.out.println(faceCount[count]);
    I'm really confused with how a the gamble library gets put into the array, so any help is appreciated! Also if anyone could explain the errors to me, I would really appreciate it.
    thanks in advance,
    wootens
    Edited by: Wootens on Oct 18, 2010 8:55 PM

    D'oh!
    Thanks you guys, fixed that. Although I'm having trouble with storing the die roll in the array. Any suggestions?
    java.io.*;
    public class CountDieFaces
        //prompt for and read in: number of times user wants to roll one die
        //simulate rolling a die that many times, counting how many times each face 1 thru 6 comes up
        //print out: each roll
        //AND the total number of times each face occured and the percentage of the time each face occured.
        public static void main(String[] args)
            Scanner scan = new Scanner(System.in);
            int[] faceCount= {0,0,0,0,0,0};
            int dice;
            System.out.println("How many times would you like to roll the die?");
            int dieCount = scan.nextInt();
            int dieRoll = rollDie(); // Main calling class method
            int count = 0;
            while(count < dieCount)
                System.out.println(faceCount[dieRoll]);
                count++;
        public static int rollDie()
            int dieRoll = (int)(Math.random()*6)+1;
            return dieRoll;
    }Wootens

  • Help with array question

    hi,
    i need some help with this piece of code. wat would it output to the screen?
    int [] theArray = { 1,2,3,4,5};
    for (int i = 1; i < 5; i++)
    System.out.print(theArray * i + "; ");
    would it output 1 * 1;
    2 * 2;...
    thanx
    devin

    Ok...
    1] Your index into the array is off by 1 - remember that array indexing starts from 0.
    2] You cannot multiply an array object. The contents? fine , go ahead but NOT the array
    so your output should be something like:
    operator * cannot be applied to int[] :d
    try
    int[] theArray = {0,1,2,3,4,5};
    for(int i = 1;i<6;i++)
         System.out.print(theArray*i+";");
    giving you an output of 1;4;9;16;n...
    if you were looking for the output stated change
    System.out.print(theArray*i+";");
    to
    System.out.print(theArray[i]+"*"+i+";");done...

  • Need Help with Array.sort and compare

    Hi
    I have a big problem, i try to make a java class, where i can open a file and add new words, and to sort them in a right order
    Ok everthing works fine, but i get a problem with lower and upper cases.
    So i need a comparator, i tried everything but i just dont understand it.
    How do i use this with Array.sort??
    I hope someone can help me

    Okay, you want to ignore case when sorting.
    There are two possibilities: Truly ignore case, so that any of the following are possible, and which one you'll actually get is undefined, and may vary depending on, say, which order the words are entered in the first place:
    English english German german
    english English german German
    English english german German
    english English German german
    The second possibility is that you do consider case, but it's of lower priority--it's only considered if the letters are the same. This allows only the first two orderings above.
    Either way, you need to write a comparator, and call an Arrays.sort method that takes both array and Comparator.
    The first situation is simpler. Just get an all upper or lower case copy of the strings, and then compare thosepublic int compare(Object o1, Object o2) {
        String s1 = ((String)o1).toUpper();
        String s2 = ((String)o1).toUpper();
        return s1.compareTo(s2);
    } You'll need to add your own null check if you need one.
    For the second way, your comparator will need to iterate over each pair of characters. If the characters are equal, ignoring case, then you compare them based on case. You pick whether upper is greater or less than lower.
    Of course, the need to do this assumes that such a method doesn't alrady exist. I don't know of one, but I haven't looked.

  • Please Help With Arrays

    I really need some help with the following two methods:
    - A method fillArray() that accepts an integer array as a parameter and fills the array with random integers. I am encouraged to use Math.random()
    - A method printArray() that accepts an integer array as a parameter and outputs every element of the array to the standard output device. I am encouraged to use print instead of println in order to save paper.
    Thanks so much for your help.

    public class Test {
       public static void main (String[] args){
           int[] intArray = new int[20];
           fillArray(intArray);
           printArray(intArray);
       public static void fillArray (int[] intArray){
           for (int i = 0; i < intArray.length; i++) {
               intArray[i] = (int) (Math.random()*1000);
       public static void printArray (int[] intArray){
           for (int i = 0; i < intArray.length; i++) {
               int i1 = intArray;
    System.out.print(i1+",");
    System.out.println("");

  • Need Help with Arrays/Text

    I'm trying to create a flash program that uses it's own code to send and create images. Each square has a colour and that colour gets added into the array. A black, then grey, then white is:
    filecode = ["Bl", "Gr", "Wh"];
    That works fine, but when I try to paste it into an Input text box it will only fill in the first part of the array.
    filecode = ["Bl,Gr,Wh"];
    So the program has NO idea what I want.
    The only ways I can think of fixing this is by putting in 402 text boxes to suit every box...But every one of them needs a Variable Name.
    Or by sending the information straight into the array. But this way you are just looking at what you just drew, and that is not at ALL practical.
    Helping me with this headache will be greatly apprectiated.
    FlashDrive100.

    If you can explain the first part of your posting it might become a little clearer what you are trying to do and what isn't working... particularly this...
    " when I try to paste it into an Input text box it will only fill in the first part of the array."
    I can't speak for anyone else, but at this point, I share your file's problem... not knowing what you want.

  • Help with arrays and Exception in thread "main" java.lang.NullPointerExcept

    Hi, I have been having trouble all day getting this array sorted and put into a new array. I think it is something simple with my nested loops in sortCityArray() that is causing the problem. Any help would be greatly appreciated. The error is thrown on line 99 at Highway.sortCityArray(Highway.java:99)
    import java.util.Scanner;
    import java.io.*;
    import java.util.Arrays;
    public class Highway
    private String[] listOfCities=new String[200];
    private City[] cityArray=new City[200];
    private City[] sortedCityArray=new City[200];
    private String city="";
    private String city2="";
    private String fileName;
    private City x;
    private int milesToNextCity;
    private int milesAroundNextCity;
    private int speedToNextCity;
    public Highway(String filename)
    String fileName=filename;//"I-40cities.txt";
           File myFile = new File(fileName);
           try {
           Scanner scan=new Scanner(myFile);
           for(int i=0; scan.hasNextLine(); i++){
           String city=scan.nextLine();
           String city2=scan.nextLine();
           int milesToNextCity=scan.nextInt();
           int milesAroundNextCity=scan.nextInt();
           int speedToNextCity=scan.nextInt();
                   if(scan.hasNextLine()){
              scan.nextLine();
           cityArray=new City(city,city2,milesToNextCity,milesAroundNextCity,speedToNextCity);
    // System.out.println(cityArray[i].getCity());
    // System.out.println(cityArray[i].getNextCity());
    // System.out.println(cityArray[i].getLengthAB());
    // System.out.println(cityArray[i].getLengthAroundB());
    // System.out.println(cityArray[i].getSpeedAB());
    catch (Exception e) {
    System.out.println(e);
    //return cityArray;
    /*public City[] doCityArray(){
    File myFile = new File(fileName);
    try {
    Scanner scan=new Scanner(myFile);
    for(int i=0; scan.hasNextLine(); i++){
    String city=scan.nextLine();
    String city2=scan.nextLine();
    int milesToNextCity=scan.nextInt();
    int milesAroundNextCity=scan.nextInt();
    int speedToNextCity=scan.nextInt();
         if(scan.hasNextLine()){
              scan.nextLine();
    cityArray[i]=new City(city,city2,milesToNextCity,milesAroundNextCity,speedToNextCity);
    // System.out.println(cityArray[i].getCity());
    // System.out.println(cityArray[i].getNextCity());
    // System.out.println(cityArray[i].getLengthAB());
    // System.out.println(cityArray[i].getLengthAroundB());
    // System.out.println(cityArray[i].getSpeedAB());
    catch (Exception e) {
    System.out.println(e);
    return cityArray;
    public City[] sortCityArray(){
    sortedCityArray[0]=new City(cityArray[0].getCity(),cityArray[0].getNextCity(),cityArray[0].getLengthAB(),cityArray[0].getLengthAroundB(),cityArray[0].getSpeedAB());
    for(int j=0; j<cityArray.length; j++ )
         for(int i=0; i<cityArray.length ;i++)
              if(sortedCityArray[j].getNextCity().equals(cityArray[i].getCity())){
              sortedCityArray[j+1]=new City(cityArray[i].getCity(),cityArray[i].getNextCity(),cityArray[i].getLengthAB(),cityArray[i].getLengthAroundB(),cityArray[i].getSpeedAB());
              break;
    /*     for(int i=0; i<cityArray.length ;i++)
              if(sortedCityArray[j].getNextCity().equals(cityArray[i].getCity())){
              sortedCityArray[j+1]=new City(cityArray[i].getCity(),cityArray[i].getNextCity(),cityArray[i].getLengthAB(),cityArray[i].getLengthAroundB(),cityArray[i].getSpeedAB());
         break;
              for(int i=0; i<cityArray.length ;i++)
              if(sortedCityArray[j].getNextCity().equals(cityArray[i].getCity())){
              sortedCityArray[j+1]=new City(cityArray[i].getCity(),cityArray[i].getNextCity(),cityArray[i].getLengthAB(),cityArray[i].getLengthAroundB(),cityArray[i].getSpeedAB());
         break;
              for(int i=0; i<cityArray.length ;i++)
              if(sortedCityArray[j].getNextCity().equals(cityArray[i].getCity())){
              sortedCityArray[j+1]=new City(cityArray[i].getCity(),cityArray[i].getNextCity(),cityArray[i].getLengthAB(),cityArray[i].getLengthAroundB(),cityArray[i].getSpeedAB());
         break;
    //     j++;
    System.out.println(sortedCityArray[0].getCity());
    System.out.println(sortedCityArray[0].getNextCity());
    System.out.println(sortedCityArray[0].getLengthAB());
    System.out.println(sortedCityArray[0].getLengthAroundB());
    System.out.println(sortedCityArray[0].getSpeedAB());
    System.out.println(sortedCityArray[1].getCity());
    System.out.println(sortedCityArray[1].getNextCity());
    System.out.println(sortedCityArray[1].getLengthAB());
    System.out.println(sortedCityArray[1].getLengthAroundB());
    System.out.println(sortedCityArray[1].getSpeedAB());
    System.out.println(sortedCityArray[2].getCity());
    System.out.println(sortedCityArray[2].getNextCity());
    System.out.println(sortedCityArray[2].getLengthAB());
    System.out.println(sortedCityArray[2].getLengthAroundB());
    System.out.println(sortedCityArray[2].getSpeedAB());
    System.out.println(sortedCityArray[3].getCity());
    System.out.println(sortedCityArray[3].getNextCity());
    System.out.println(sortedCityArray[3].getLengthAB());
    System.out.println(sortedCityArray[3].getLengthAroundB());
    System.out.println(sortedCityArray[3].getSpeedAB());
    System.out.println(sortedCityArray[4].getCity());
    System.out.println(sortedCityArray[4].getNextCity());
    System.out.println(sortedCityArray[4].getLengthAB());
    System.out.println(sortedCityArray[4].getLengthAroundB());
    System.out.println(sortedCityArray[4].getSpeedAB());
    return cityArray;
    /*public String[] listOfCities(){
    File myFile = new File("I-40cities.txt");
    try {
    Scanner scan=new Scanner(myFile);
    for(int i=0; scan.hasNextLine(); i++){
         String city=scan.nextLine();
         city=city.trim();
    scan.nextLine();
    scan.nextLine();
         listOfCities[i]=city;
         System.out.println(listOfCities[i]);
    catch (Exception e) {
    System.out.println(e);
    return listOfCities;
    public static void main(String args[]) {
    Highway h = new Highway("out-of-order.txt");
    h.sortCityArray();

    the ouput is perfect according to the print lines if I use (increase the int where j is in the loop manually by one) :
         for(int i=0; i<cityArray.length ;i++)
              if(sortedCityArray[0].getNextCity().equals(cityArray.getCity())){
              sortedCityArray[0+1]=new City(cityArray[i].getCity(),cityArray[i].getNextCity(),cityArray[i].getLengthAB(),cityArray[i].getLengthAroundB(),cityArray[i].getSpeedAB());
              break;
         for(int i=0; i<cityArray.length ;i++)
              if(sortedCityArray[1].getNextCity().equals(cityArray[i].getCity())){
              sortedCityArray[1+1]=new City(cityArray[i].getCity(),cityArray[i].getNextCity(),cityArray[i].getLengthAB(),cityArray[i].getLengthAroundB(),cityArray[i].getSpeedAB());
         break;
              for(int i=0; i<cityArray.length ;i++)
              if(sortedCityArray[2].getNextCity().equals(cityArray[i].getCity())){
              sortedCityArray[2+1]=new City(cityArray[i].getCity(),cityArray[i].getNextCity(),cityArray[i].getLengthAB(),cityArray[i].getLengthAroundB(),cityArray[i].getSpeedAB());
         break;
              for(int i=0; i<cityArray.length ;i++)
              if(sortedCityArray[3].getNextCity().equals(cityArray[i].getCity())){
              sortedCityArray[3+1]=new City(cityArray[i].getCity(),cityArray[i].getNextCity(),cityArray[i].getLengthAB(),cityArray[i].getLengthAroundB(),cityArray[i].getSpeedAB());
         break;
    But I cant do this for 200 elements. Are the loops nested right?
    Edited by: modplan on Sep 22, 2008 6:49 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Help with indexing in PHP

    Hello,
    I use dbxml version 2.2.13 with PHP.
    I am trying to index a document but seems that without success because the performance doesn't change.
    The doc has 1600 elements and executing a query takes about 0.22 secs
    The xquery looks like this (a bit simplified):
    <pre>
    declare namespace ns1 = "urn:...";
    declare function local:foo ($p1 as element(), $p2 as element()) as item() {
    let $a := data($p2/AAA)
    let $b := data($p2/BBB)
    let $r := $p1//CCC/*[name()=\$a][@ns1:attr1=\$b]
    return $r/DDD
    local:foo( doc("...")/*[1] , ... )
    </pre>
    I create the container like this:
    $mgr->createContainer($qcname,DBXML_INDEX_NODES);
    I have 4 questions:
    Q1) Which index strategy should I take?
    I have tested using "CCC" , "node-element-presence-none" but no speed up occurs.
    The qplan shows sth like:
    <OQPlan>P(node-element-presence-none,=,CCC)</OQPlan>
    So seems the index is correctly set.
    It is strategy ok? Which other indexes should I use?
    Q2) should the indexes be inserted before or after inserting the document, or is this irrelevant?
    Q3) If I create the container from php as shown before, and then I open it with dbxml it shows:
    Type of default container: NodeContainer
    Index Nodes: off
    However if I create the container directly from dbxml it
    Type of default container: NodeContainer
    Index Nodes: on
    Why is that?
    Q4) I need to repeat several times $mgr->query(....) . Does this affect somehow the data base acces performance?
    I'd be glad if someone could help me to make the indexes work..
    Best,
    /Enric

    Q2) should the indexes be inserted before or after
    inserting the document, or is this irrelevant?In the sense that this will not affect what the indexes contain, this is irrelevent. However, we normally recommend adding indexes before documents, or you would risk a lengthy re-index operation.
    Q3) If I create the container from php as shown
    before, and then I open it with dbxml it shows:
    Type of default container: NodeContainer
    Index Nodes: off
    However if I create the container directly from dbxml
    it
    Type of default container: NodeContainer
    Index Nodes: on
    Why is that?This is a bug in the PHP API - it is also why your indexes made no difference for you. You will need to create your container outside PHP using DBXML_INDEX_NODES.
    Q4) I need to repeat several times $mgr->query(....)
    . Does this affect somehow the data base acces
    performance?If the query is run several times, you would benefit from preparing it once, and executing it from the XmlQueryExpression object.
    John

  • Help with array program!!

    hi friends
    i am a new comer to java and I have been studying Arrays recently. I came across this program on the internet ( thanks to Peter Williams)
    package DataStructures;
    import java.util.NoSuchElementException;
    * An array implementation of a stack
    * @author Peter Williams
    public class StackArray implements Stack {
    private int top; // for storing next item
    public StackArray() {
    stack = new Object[1];
    top = 0;
    public boolean isEmpty() {
    return top == 0;
    public void push(Object item) {
    if (top == stack.length) {
    // expand the stack
    Object[] newStack = new Object[2*stack.length];
    System.arraycopy(stack, 0, newStack, 0, stack.length);
    stack = newStack;
    stack[top++] = item;
    public Object pop() {
    if (top == 0) {
    throw new NoSuchElementException();
    } else {
    return stack[--top];
    interface Stack {
    * Indicates the status of the stack.
    * @return <code>true</code> if the stack is empty.
    public boolean isEmpty();
    * Pushes an item onto the stack.
    * @param <code>item</code> the Object to be pushed.
    public void push(Object item);
    * Pops an item off the stack.
    * @return the item most recently pushed onto the stack
    * @exception NoSuchElementException if the stack is empty.
    public Object pop();
    class StackDemo {
    public static void main(String[] args) {
         Stack s = new StackArray();
         // Stack s = new StackList();
         for (int i = 0; i < 8; i++) {
         s.push(new Integer(i));
         while (!s.isEmpty ()) {
         System.out.println(s.pop());
    what baffles me is as below:
    there is an 'if' construct in the push method, which talks about if(top == stack.length)
    I fail to understand how top can at any time be equal to stack.length.
    Could you help me understand this program?
    a thousand apologies and thanks in advance

    figurativelly speaking:
    if you take an array and put it standing on your tesk, so that start of array points to floor, and end of array points to roof, then you can start filling that array as stack.
    if you put books into stack, then you push (put) them on top of the stack, so the first book ever but into stack is adiacent to array element with index zero (0) and then second book in stack would be adiacent to array element that has index one (1) and so on.
    if you have array of size 5, then fift book in stack would be adiacent to array element with index four (4)
    after pushing that Object to stack, the top variable will get incremented (top++ in code) and be equal to size of array.
    however, if you would like to push another Object to stack, then it would fall over the end of the array, so longer array is needed...

  • Help with Mac Dreamweaver PHP

    Well, I finally have PHP embedded within HTML working however the directory structure is totally confusing me.  I place files is /MAMP/htdocs and yet nothing works unless I add /MAMP/htdocs/htdocs and place the index and other php files ALSO in there.  I must open the ones in /MAP/htdocs and yet when I run them using my test server the files in /MAMP/htdocs/htdocs are the ones that are actually used.
    My configuration in SITES is
    Test Server
    local/network
    /Applciations/MAMP/
    http://localhost:8888/
    I would appreciate help understanding how to properly configure DreamWeaver SITE so that I can place all files in the MAMP/htdocs directory and eliminate the reducntant one.
    Thanks,
    Rick

    If you're using MAMP, your DW local site folder should be something like this:
    /Applications/MAMP/htdocs/sitename
    Because htdocs is the default folder MAMP routes to as localhost. Whatever site you have within htdocs folder will be suffixed with localhost in your browser for testing.
    For example, your site files (working files) can be put in a folder and that folder should be placed within 'htdocs' folder in MAMP Application folder.
    Say, you have a folder called 'test' containing index.php and this folder is placed within htdocs, your DW local site folder will be:
    /Applications/MAMP/htdocs/test
    To check this in browser, you'll simply enter
    http://localhost:8888/test
    This will run the index.php file within test folder by default.
    Your testing server can be the same as 'localhost:8888/test' for the site.
    If you want your Remote FTP also configured, enter your webhost's details and get that configured.
    -ST

  • Need Small Help with Arrays.

    I have this question i wanna ask...Could anyone help me with this code.
    Assume that the array arr has been declared. how do i write a statement that assigns the next to last � element of the array to the variable x , which has already been declared.

    Of course, if you don't know the size until run time, you'll want to check that the array size is greater than 1, else there won't BE a next to last element.

  • Help with flash and php prlblem

    the problem is flash receive the data back after send
    loadvars.but it always got it wrong.
    code in flash is:
    send_btn.onRelease = function() {
    myVars = new LoadVars();
    myVars.username = username_txt.text;
    myVars.phonenum = phonenum_txt.text;
    myVars.picktime = picktime_txt.text;
    myVars.email = email_txt.text;
    myVars.address = address_txt.text;
    myVars.shortmessage = shortmessage_txt.text;
    myVars.onLoad = function(success) {
    if (success) {
    if (this.order) {
    gotoAndStop(2);
    } else {
    gotoAndStop(3);
    delete myVars;
    myVars.sendAndLoad("sendorder.php", myVars, "POST");
    and code in php is:
    $username = $_POST['username'];
    $phonenum = $_POST['phonenum'];
    $picktime= $_POST['picktime'];
    $email = $_POST['email'];
    $address = $_POST['address'];
    $shortmessage= $_POST['shortmessage'];
    $result=mysql_query("insert into
    userinfo(email,username,phonenum,address,picktime,message)
    values('$email','$username','$phonenum','$address','$picktime','$shortmessage')");
    if($result){
    echo "order=1";
    }else{
    echo "order=0";
    flash reponse after receiving the varaible from php is always
    go to frame 3
    but the test of php is output order=1.
    what is wrong with it?please help::^_^

    interesting b, but i think i see something else here that is
    the reason you needed to add the '&'. You're passing back a
    number value (ie. 0/1) and treating it as a boolean (all fine)
    except that in the echo statement it's all inside quotes, so it's
    being interpreted as a complete String. to remedy, try writing the
    echo like this:
    if($result) {
    echo('order='.1);
    }else{
    echo('order='.0);
    and you're welcome :)

  • Help with arrays...Please Help

    Hello,
    Iam trying to make a library system. I have three classes, one for the GUI, User class, and Users class. User class instantiates an object with all the relevant data like, Name, Age, Address, etc. The Users class contains a array of User Objects.
    With this program I have to be able to create users, display users and delete users. The problem Iam having is displaying them. (I think I correctly store the User Objectsin the array, and Iam having problems retreiving them). The thing is when I run the program I don't get any exception errors, just nothing gets displayed!
    Here is part of my code:
    public class Users {
    //declaring variables
    public Users (){
    initialiseArray();
    public void initialiseArray(){
    userArray = new User [50];
    // This method first checks to see if there is enough room for a new
    // user object. If there is the object is added to the array, if there is'nt
    // Then method expandUserArray is called to make room for the user
    public void addUser( User user)
    if (userArraySize == userArray.length) {
    expandUserArray();
    userArray[userArraySize] = user;
    userArraySize++;
    // In this method first the user is searched for in the array, if found
    // Then method decreaseUserArray is called to delete the user
    public void deleteUser ( User user )
    location = 0;
    while (location < userArraySize && userArray[location] != user) {
    location++;
    if (userArray[location] == user) {
    decreaseUserArray(location);
    public void displayUsers( ){
    for (int i = 0; i < userArraySize; i++) {
    usersInformation += "\n" + (userArray.getUserName());
    usersInformation += "\t" + (userArray[i].getUserID());
    usersInformation += "\t" + (userArray[i].getUserAddress());
    public String getUserInformation(){
    //usersInformation = userInformation.toString();
    return usersInformation;
    // The User is deleted by shifting all the above users one place down
    private void decreaseUserArray(int loc)
    userArray[loc] = userArray[userArraySize - 1];
    userArray[userArraySize - 1] = null;
    userArraySize--;
    // This method increase the size of the array by 50%
    private void expandUserArray( )
    int newSize = (int) (userArray.length * increasePercentage);
    User newUserArray[] = new User[newSize];
    for (int i = 0; i < userArray.length; i++) {
    newUserArray[i] = userArray[i];
    userArray = newUserArray;
    Is there anything wrong with my arrays??? Here is part of my code for action performed:
    void addUserButton_actionPerformed(ActionEvent e) {
    newUserName = userNameTextField.getText();
    newUserAddress = userAdressTextField.getText();
    newUserID = Integer.parseInt ( userIDTextField.getText());
    User newUser = new User (newUserName, newUserAddress, newUserID);
    Users users = new Users();
    users.addUser(newUser);
    clearButton();
    void displayUsersButton_actionPerformed(ActionEvent e) {
    Users users = new Users();
    users.displayUsers();
    displayUsersTextArea.append (users.getUserInformation());
    void deleteUserButton_actionPerformed(ActionEvent e) {
    //Still incomplete
    Thanks for your help!

    First, PLEASE USE THE SPECIAL TOKENS FOUND AT
    http://forum.java.sun.com/faq.jsp#messageformat WHEN
    POSTING CODE!!!! Sorry about that, Iam new and I did'nt know about Special Tokens.
    As far as the problem, let me start out by asking if
    you've considered using a class that implements the
    List interface. Perhaps Vector or ArrayList would
    make a better choice since they already handle
    "growing" and "shrinking" for you.I tried using vector arrays but it got too complicated. It was very easy to add and remove objects from the vector but I never figured out how to display all the objects with all the data.
    public void displayUsers( ){
    for (int i = 0; i < userArraySize; i++) {
    usersInformation += "\n" +
    " + (userArray.getUserName());   //what is
    usersInformation?  Also, how does getUserName(),
    getUserID(), getUserAddress() know which user object
    to operate on if these are methods of userArray?
    usersInformation += "\t" +
    " + (userArray.getUserID());     //I'm guess you've
    only posted "some" of your code. 
    usersInformation += "\t" +
    " + (userArray.getUserAddress());//Try posting all
    that you have so far, and please use the special
    tokens to format your code.
    }I made a mistake while I was cutting & pasting my code. It should be for example:
    usersInformation += "\n" (userArray.getUserName());
    The comment about instanciating a new Users for each
    actionPerformed is on point. You are replacing your
    Usres with a new object each time.Yep this was the problem. I just changed the constructor, declared and
    created object of Users elsewhere.
    Thanks for your help!

  • Help with Array of Arrays

    import java.util.Arrays;
    import java.util.Date;
    import java.util.List;
    public class StockDay
        private String[] stockDayData;
        List stockDays = new ArrayList();
        public StockDay(String stockData)
            stockDayData = new String[6];
            String[] stockDayData= stockData.split(",");
            stockDays.add(stockDayData[]);
    }I have an outside class calling this class with a string of data separated by commas. I am trying to separate the data so that each time the method is called, each piece of the data (6 total) is put into an array list. Then that array list is put into an array list of arrays. I am sorry if I have not made this clear, I will try again. I want an array of arrays, and the interior arrays will contain 6 pieces of information each from the string that is given to the method, and each separated by commas.
    Any help is much appreciated. I am also curious how I can accesses one piece of the data at a time, this is what I am thinking for this:
    data = arraylist1[#].arraylist2[#]this would set data equal to whatever is in arraylist2[#]
    Thank you very much.

    ActingRude wrote:
    I meant just a simple Array I guess.Note the difference between Array and array. Class names start with uppercase in java. There is a class called Array, but it's just a utility class, and isn't part of arrays.
    .. like I am using above? I was under the impression that the biggest syntax difference between an array(fixed number of items) and an ArrayList(unfixed number of items) was the use of the [] and () That's one of many syntactical differences, yes, but the main difference is not in the syntax. arrays are part of the Java language, have special handling because of that, and are faster and smaller than ArrayLists. ArrayList is part of the API, and didn't exist until Java 1.2 (about 5-6 years into Java's life, I think), and is built on top of an array.
    UnsupportedOperationException:
    null (in java.util.AbstractList)I have no idea what is causing this, I can only assume that I am doing something wrong...It looks like you're tyring to add null to an ArrayList and it doesn't like it. I thought ArrayList accepted null elements, but I could be wrong. Paste in the exact line that's causing it, and any declarations necessary to clarify any variables used on that line.

Maybe you are looking for

  • Customer Statement Report in ebs 12 - bursting error prior to xml complete

    Hello There, We are using the standard non-modified (as far as i am aware) Statement Generation Program from the AR Print Documents/Statements menu in EBS 12. When the report runs for just a few statements it completes through to bursting with no iss

  • QUICBOOKS 2007 doesn't run under snow leopard

    My register now says I have made deposits of $8, 456, 782.4301 AND they were made on 2/03/36. Intuit says "too bad so sad, we are going to release a patch for QB 2009 for MAC that MAY fix the problem, we won't support 2007" Bottom line, snow leopard

  • Clicking on Icon

    Icon appears on too;bar but after clicking on icon, email doesn't appear on monitor. I had this problem a month ago with dictionary after installing update downloads from Apple. Never bothered to check into it but now the same thing has happened with

  • Inventory_item_id in msc_system_items

    Can anyone tell me what inventory_item_id in msc_system_items represents? I know that sr_inventory_item_id is the same value as inventory_item_id in mtl_system_items_b Thanks in advance

  • Strange behaviour of the rangeSize - or is it desired?

    Hi there, as recently asked in Difference between VO Fetch Size, Iterator rangeSize and af:table Fetch Siz we have a problem with the rangeSize property of the iterator binding. First of all, we're currently working wit JDev version 11.1.2.2.0. So, w