scudzilla 32 Junior Poster

Line 164 uses $student_id but $student_id may not have been declared. This occurs when line 138 condition is false.

scudzilla 32 Junior Poster

That is because prime number i does not correspond to the index of the vector. Everytime you push a value into a vector, it takes the (n+1)th address. So, if your input is 10, i values 1, 2, 3, 5, and 7 are located at indices 0, 1, 2, 3 and 4 respectively. However, you're calling the elements at indices 1, 2, 3, 5 and 7, which you haven't assigned yet at the time each of them was called.

scudzilla 32 Junior Poster

This might make you better understand:

#include <iostream>

using namespace std;



struct sct {
    int t1[2];
};

struct str {
    sct t2[2];
};

int main(void) {
   str t3[2] = { {0, 2, 4, 6}, {1, 3, 5, 7} };
   cout << t3[1].t2[0].t1[1] << t3[0].t2[1].t1[0];
   return 0;
}


And the crude diagram of your structure values...

|-------t3[0]---------| |--------t3[1]--------|
| |-t2[0]-| |-t2[1]-| | | |-t2[0]-| |-t2[1]-| |
 {  0 , 2  ,  4 , 6  } , {  1 , 3  ,  5 , 7  }
    |   |     |   t1[1]     |   |     |   t1[1]
    |   |    t1[0]          |   |    t1[0]
    |  t1[1]                |  t1[1]
   t1[0]                   t1[0]
scudzilla 32 Junior Poster

One thing you could do, as I said, is to send just the avatar names with Post, and remove the use of $action altogether, making the script one continuous function.

scudzilla 32 Junior Poster

My $0.02

Second life calls your script with three possibilities: a) open a connection; b) insert a row and; c) close the connection

a doesn't have problems, although it does nothing meaningful. It just opens a connection to the database.

b, however, calls an instance of the script different from a and in this instance, there is no connection to the database, hence the 'vangua01'@'localhost' error (b1: according to the script, your indicated user is vangua01_admin2, not vangua01)

c is plainly does nothing at this point, and is redundant anyway because the connection automatically closes when the script ends.

Might I suggest just sending the avatarname with Post, and removing the conditions for mysql connect/close?

Once again, my $0.02

scudzilla 32 Junior Poster

checkfee is a local variable in main. Local variables have to be initialized with a value, because they have no default value. Human logic dictates that the conditions in lines 27 to 34 satisfy the entire domain of possible values of checks, meaning one of the if or else if statements will execute every time, ergo checkFee will be initialized. However, the java compiler doesn't check those conditions in that same way, and will always assume that there's a possibility that none of them will execute. It always looks for a default value, or a case that covers the anything else condition.

You can either initialize checkFee before hand, by changing line 14 to checkFee=0; or any other float value, or change line 33 else if to simply else, which satisfies the java compiler's condition of anything else.

scudzilla 32 Junior Poster

After an INSERT query, use $id = $mysqli->insert_id. It gives $id either the last auto_increment id inserted if there is one, 0 if there's no auto_increment id field, or false if the connection failed.

scudzilla 32 Junior Poster

Why not use a list? Or maybe a dictionary?

Gribouillis commented: the good solution +14
scudzilla 32 Junior Poster

First of all, your output is reversed. a<b<c check should be y, while pythagorean check should be x.

Anyway, if the output is supposed to be 0 or 1 only, then your code is still lacking. Assuming input of positive and nonequal three integers, using e=a%b, if a is greater than b, then the result of a%b would always be less than a. On the other hand, if b is greater than a, then the result of a%b would always be a. What can we do then, to make the output 0 and 1 respectively?

Follow that with f=b%c, if a is greater than b, or if b is greater than c, then one or both of e and f is 0. If one of them is 0, how can we make sure that y would be 0?

As for checking for pythagorean sets, you can do it with integers as well. If sum is less than c2 (c-squared, for simplicity), sum/c2 is 0. What if sum is greater than c2? Well, the reciprocal, c2/sum gives 0. If sum=c2, both give 1. Get the idea?

Lastly, what if a<b<c is false, while pythagorean check is true? Well, the second condition depends on the first condition anyway. So make use of y (which is equal to 0 in this case) to do something about it.

scudzilla 32 Junior Poster

Well, for starters, could you explain the relationship of lv1T1 and lv2T1? Based on the code you've posted, the only way I can see that gives that error is that at line 4, currrentrow would equal 25, while lv1T1 has 24 or less items.

scudzilla 32 Junior Poster

In that case, there's nothing wrong with the method except line 77: int highestrow = numbers[0][0] which should be int highestrow = numbers[row][0] to prevent the possibility of error if numbers[0][0] is higher than any number in all other rows.

scudzilla 32 Junior Poster

Try the onboard VGA (if yours has one). If it has output, you can check the bios and/or device manager if the graphics card is indeed not recognized.

scudzilla 32 Junior Poster

Ahh, I can't test the SCP drivers because my Bluetooth dongle broke.

Perhaps your dongle is malfunctioning?

aVar++ commented: Thank you for going to so much trouble. +3
scudzilla 32 Junior Poster

Let's say you limit your integers to be stored from -15 to 15 (31 numbers in all):
You create an array int freq[31]
You set all values in freq to 0 memset(freq, 0, sizeof(freq))
You create another array which points to the middle of freq for easy index substitution int* mid = freq + 15

Now all you have to do is: for every M[i][j], you just have to increment the corresponding mid value mid[M[i][j]]++. After all cells have been accounted for, output your mid array using index -15 to 15.

IF you do not know the limits of integers that can be stored in your matrix, perhaps it's better to use vector or struct, as David said. You'll have to sort your frequency counts if you want them to be in order for output.

scudzilla 32 Junior Poster

Hmm try this after declaring cb and before filling data_table?

cb.QuotePrefix = "["
cb.QuoteSuffix = "]"
scudzilla 32 Junior Poster

Your chrome bookmarks, passwords and other data are synced with your google account. That way, you can still access your data in another computer, provided you log in your account. I think they are planning on integrating android browser data into that sync as well (or they already have, and I haven't heard about it xD).

scudzilla 32 Junior Poster

In essence, isn't your query trying to get rows within the week starting from today, and not the week prior?

E: nevermind, it works for me >.< BTW in your first post it said May, and your most recent one is June. Which is it?

scudzilla 32 Junior Poster

If you don't use curly braces, only the command immediately after the if statement will be conditional. Any succeeding commands will not rely on the if statement. If you want more than one command to be conditional, place them in a block (use curly braces).

scudzilla 32 Junior Poster

Code

#include <stdio.h>

int main(int argc, char *argv[])
{
    int i, a, b, c, d, w1, w2, l1, l2, x, y, arr[24][4];
    i = 0;
    //just to come up with permutations
    for(a=1;a<5;a++){
      for(b=1;b<5;b++){
        for(c=1;c<5;c++){
          for(d=1;d<5;d++){
            if(!(a==b || a==c || a==d || b==c || b==d || c==d)){
            arr[i][0]=a;
            arr[i][1]=b;
            arr[i][2]=c;
            arr[i][3]=d;
            i++;
            }
          }
        }
      }
    }
    for(i=0;i<24;i++){
      //for each combination calculates max and min
      if(arr[i][0]>arr[i][1]){
        w1 = arr[i][0];
        l1 = arr[i][1];
      }
      else{
        w1 = arr[i][1];
        l1 = arr[i][0];
      }
      if(arr[i][2]>arr[i][3]){
        w2 = arr[i][2];
        l2 = arr[i][3];
      }
      else{
        w2 = arr[i][3];
        l2 = arr[i][2];
      }
      if(w1>w2)
        x = w1;
      else
        x = w2;
      if(l1<l2)
        y = l1;
      else
        y = l2;

      printf("%d%d%d%d - %d %d\n", arr[i][0], arr[i][1], arr[i][2], arr[i][3], x, y);
    }
    system("PAUSE");    
    return 0;
}

Output

1234 - 4 1
1243 - 4 1
1324 - 4 1
1342 - 4 1
1423 - 4 1
1432 - 4 1
2134 - 4 1
2143 - 4 1
2314 - 4 1
2341 - 4 1
2413 - 4 1
2431 - 4 1
3124 - 4 1
3142 - 4 1
3214 - 4 1
3241 - 4 1
3412 - 4 1
3421 - 4 1
4123 - 4 1
4132 - 4 1
4213 - 4 1
4231 - 4 1
4312 - 4 1
4321 - 4 1
scudzilla 32 Junior Poster

Er, it's there. under "Tags: Click to add Tags..."

It's a cropped image showing part of the taskbar.

@OP you could try refreshing the icon cache

scudzilla 32 Junior Poster

You're gonna check each character one by one if it is in fact a digit.

scudzilla 32 Junior Poster

relations[] is an array of double.

relations[i] is just a double, not an array of double. It is, of course, not compatible to double[8] which is an array of double.

scudzilla 32 Junior Poster

Yea, that's good. Just remember to use the parameter name in the query.

You don't need to define the parameters in the front-end, so no need for Dims. They need to be defined in the back-end, and the Parameters.AddWithValue does exactly that.

scudzilla 32 Junior Poster

1) Yes, we define the search criteria. WHERE specifies conditions for the search. @lastName and @phone are parameters. au_lname like @lastName means that we are looking for records such that au_lname field is similar to whatever @lastName holds. AND phone like @phone, we are looking for records where phone field is similar @phone value in addition to the lastname condition. For more information on SQL syntax, click me.

2) Those lines basically define the parameters and set their values.

scudzilla 32 Junior Poster

^That. And with ds being empty, the dgv would of course be blank. Correct me if I'm wrong, but shouldn't strings in the query be between single quotes?

scudzilla 32 Junior Poster

First of all, unless you place all those pictureboxes in a list<of pictureboxes>, you cannot fill them using a loop; you're gonna have to fill them manually.

Secondly, there is no need for con.Open.

scudzilla 32 Junior Poster

Ok. If that's the case, there's no need retrieve the record(s) with the highest number of votes.

You could use a DataAdapter instead of DataReader for your sqlcouncil query (and select all fields, not just num_of_votes), place the result into a DataTable, and retrieve the first 8 rows.

scudzilla 32 Junior Poster

Anyway, you should use the correct value in your Case: either 0x57 or 87, but not 57 which is the decimal ascii value of 9. That's only for capital W, so small w will not increment score.

scudzilla 32 Junior Poster

Capital W is 57h or 87d. Small w is 77h or 119d.

scudzilla 32 Junior Poster

Ok. I downloaded Bloodshed Dev-C++ 5 to try and compile your code (lots of syntax error before / token, and for loop initial declaration used outside C99 mode >.<) and I still get all the expected output..

OH, you wrote this in a cpp file instead of a c file?

Er.. even after running it as c or cpp file, I still get all output.

Last edit:... Maybe your command prompt is limited to 300 lines, which is why you see only the last 300 lines of output? =/

el33t commented: Your hint to check the command prompt properties worked!! +0
scudzilla 32 Junior Poster

How about using substring?

Johannady2 commented: yeah.. I tried substring and length.. it works now :D +0
scudzilla 32 Junior Poster

at line 35:

System.out.println("" + firstletter1 + firstletter2 + firstletter3 + firstletter4 + firstletter5);

Also note that because of lines 23 to 27 of your code, all strings str1 to str5 will have the same value which is equal to the last string you input. Move those lines outside of the for loop and enter the index manually. Or you can make str a string array as well. It's your choice.

Johannady2 commented: Now... i'm trying to convert the first letters to uppercase. can you help me. http://www.daniweb.com/software-development/java/threads/422406/help-touppercase-first-lettters-using-for-loop +0
scudzilla 32 Junior Poster

Even if I chose not to decide, I still made a choice.

codeorder commented: ;), xD +0
scudzilla 32 Junior Poster

Isn't it because you used mo[j-1] instead of mo[j]?

scudzilla 32 Junior Poster

Oh, now I know why you're getting out of ranges and nonetype elements. You confused the element number with the length. Suppose you create a list x with length 5. Wouldn't the contents of x be (0 to 4)? Or to put it another way, if you create a list x with elements (0 to 5), wouldn't the length be 6? Meaning, for any list x with elements (0 to n), len(x) = n+1. Let's go over the steps in the wikipedia page (note in the following statements, I renamed your list n to list x to avoid confusion with the element n):

Step 1:
a)Create array a with size n+1 (n being the index), or in other words, with size len(x). But you defined a with size len(x)+1

Step 2: arrays b and d with size n, or len(x)-1. But you defined them with size len(x)

Step 3: array h with size n, or len(x)-1 - same as step 2

Step 4: array g with size n - same as step 2

Step 5: arrays c, lo, mo, zo with size n+1 or len(x) - same as step 1

Step 6: you've done it ok

Step 7: for i = 1,...,n-1 which translates to for i in range(1,len(x)-2) but you wrote for i in range(1,len(x)-1)

Step 8: lo(n), zo(n) and c(n) or lo(len(x)-1), zo(len(x)-1) and c(len(x)-1) respectively, but you wrote lines 50 to 52 instead

Step 9: for j = n-1, n-2,...,0 which translates to for j in …

scudzilla 32 Junior Poster

Strange, I'm not encountering any error, except the unindent issues at lines 63 to 66.

scudzilla 32 Junior Poster

On second thought, it's not definite that I could recreate those errors in my own code. Is it possible for you to post the rest of the code?

scudzilla 32 Junior Poster

Hmm lemme compile the code. Unfortunately I'll have to recreate the rest of the code so it'll take some time.

scudzilla 32 Junior Poster

Anyway, on your problem is that for every else if statements, you added a semicolon after the condition. You are not supposed to do that. Additionally, you're missing another equal sign at line 53.

scudzilla 32 Junior Poster

Do arrays m and n have fixed sizes? If so, what are the sizes? If not, is it possible for len(m) to be greater than or equal to len(n) - 2?

scudzilla 32 Junior Poster

Your array of n has a maximum index of len(n) - 1. Your counter i ranges from 0 to len(n) - 1. So far so good. However, at line 14, you're trying to access the (i+1)th element of array n. What happens once i = len(n)-1? i would be equal to len(n), which exceeds the maximum available index of len(n)-1, hence the index out of range.

@pyTony I think m and n are already defined, just not included in the "part" of the code s/he posted here. I may be wrong though.

scudzilla 32 Junior Poster

The keyboard's Enter key gives a combination of two characters: carriage return (\r, ascii=13) and newline (\n, ascii=10). Since you're reading only one character, the character that is read is the first one which is carriage return. Look them up for their functions :) (Forgot to mention the combination is for Windows systems. Other systems may differ)

scudzilla 32 Junior Poster

Try changing line 51 with if((c = getch())==13), 13 being the ascii of the character of carriage return.

scudzilla 32 Junior Poster

Just use an if-else statement and a pair of counters within one of the for loops. (preferably the 2nd for loop)

scudzilla 32 Junior Poster

That happens because you are trying to access the elements of an empty vector. You could do two things: first would be to resize the vector after you input the number of students (syntax: Grades.resize(num); or, initialize the vector entirely after the number of students is entered (aka move line 9 to line 15, and include num as the size)

scudzilla 32 Junior Poster
  1. You are storing the number of students into i, which gets reassigned a new value. Store the number of students into another integer variable (num, perhaps?).
  2. At lines 15 and 23, you use i for the counter, starts at 0, but your condition is that it will end once i is greater than or equal to 0 which means your for loops do nothing at all. You are supposed to use another integer variable (num) at the condition. for(i = 0; i < num; i++);
scudzilla 32 Junior Poster

The character array pass cannot find a null value after the last password character. It will continue to read beyond the last character until it finds a null value (on or before the 30th byte after the first character). That is why the pass read at Line 93 may include additional garbage characters, hence the inequality with the password read in the file. To rectify it, add a pass[i] = 0; between lines 88 and 89 to let the program know where the true password ends.

scudzilla 32 Junior Poster

Ok. I tried the code, typed in 50 as input and got the first 50 in an instant. Even with 100 as input, it gives out everything instantaneously.

scudzilla 32 Junior Poster

Create a dynamic bigint array, initialize it with size input, and modify the rec function. I have actually created the code, just have to test it. I'll post it if it works. By the way, did you really get the first 30 stns instantly? I got the first 10 instantly, had to wait a couple of seconds for 11th, a little longer for 12th and I didn't have the patience to wait for 13th.

joankim commented: thanks for doing this with me :) +1
scudzilla 32 Junior Poster

Probably because at line 43, you used int(x) instead of just x? x at that point far exceeds the max value for an integer.
Also, at the example you posted above, total/x are long and incrementer is float.