scudzilla 32 Junior Poster

Never assign raw data directly to an uninitialised pointer. If done so, where would the pointer point to? Where will the raw data be stored? Maybe it will compile, maybe it won't. Maybe it could lead to disastrous effects. You have to make sure a pointer points to something (safe) before using it. So: char *st="myname"is plain wrong.

Anyway, a pointer variable, declared with an asterisk operator, ie: char * a;, is a variable that contains an address. This pointer still needs to be assigned, so let's say we assign st's (an array) address to it: a = st;Printing a, then, will show the address of st's first element, wherever it is in memory. By using a dereference operator (asterisk), you can access the value in the address that the pointer points to, ie: cout << *a shows st's first element.

An array is a block of memory reserved depending on the indicated size. By using the name in conjunction with an index, it's use is similar to a pointer in such that the value located in the array's first element address, offset by the index is being accessed. The main difference between the two is that arrays have fixed addresses, whereas pointers can be reassigned different addresses.

Examples:

char st[] = "myname";
char * a = st; // valid, because pointers can be assigned new addresses as values
st = a; //invalid, because array addresses are fixed

cout << *a; // outputs st[0]
a = &st[1]; // assigns …
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

Each image has a file name, and a parent directory (path). What does the images_path field in your database hold? File name, path, or both?

$src=$file_path.'/'.$row["images_path"];

Your code already concatenates the path regardless of your images_path value. If that field also contains the path, then you will of course have duplicate path, which is wrong.

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

For field names, you don't need apostrophes, only square brackets.

For example, assuming Block No, Lot No, Number of Occupants and Age need integers:

oleDbCmd.CommandText = "insert into  [Personal Data] ([Block No], [Lot No],[Number of Occupants],[First Name],[Family Name],[Date of Birth],Age, [Blood Type], [Place of Birth], Religion) values (" + this.textBox1.Text + "," + this.textBox2.Text + "," + this.textBox3.Text + ",'" + this.textBox4.Text + "','" + this.textBox5.Text + "','" + this.textBox6.Text + "'," + this.textBox7.Text + ",'" + this.textBox8.Text + "','" + this.textBox9.Text + "','" + this.textBox10.Text + "');";

Notice the text of textboxes 1, 2, 3 and 7 are not surrounded by apostrophes (because their fields are integer types).

scudzilla 32 Junior Poster

If your field needs numbers, you won't need apostrophes surrounding your value. I suspect the Block No., Lot No., ages, Number of xxx etc. needs integers? Even the date of birth fields, perhaps you've set them up as date or datetime?

Anyway, as our resident Reverend Jim always says regarding database applications, use parameterized queries. Using such prevents injections in your queries, and may save you headaches caused by data type mismatch problems.

scudzilla 32 Junior Poster

For field names with spaces, encapsulate them in square brackets. If you still encounter syntax errors in your queries, try displaying them into message boxes before executing them, and post the queries here.

scudzilla 32 Junior Poster

Try this.

scudzilla 32 Junior Poster

Basically, you decide the path by going through the higher of the two numbers starting with row 2, and consequently ending up with a binary choice for every row, while disregarding further choices in the other paths.

You should check the result of each path and find the maximum sum among the paths.

scudzilla 32 Junior Poster

Often times, the site takes too long to load. Occasionally, I get a "waiting for available socket" when that happens (chrome status).

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

Have you tried SerialPort.Write method? You want to send that as a string or as a numeric value? Also, please post your code if possible so we can understand the problem better.

scudzilla 32 Junior Poster

You get the GridBagLayout and Inset errors, because you have yet to import them.

import java.awt.GridBagConstraints; //you replaced this with the static one
import java.awt.Insets;

Furthermore, check your new GridBagConstraints initialisations: you have two arguments missing after the Insets.

scudzilla 32 Junior Poster

Which marker are you trying to set the center to? If it's one of the markers you get from the XML, which one of them (since there can be more than one)?

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

The contents of listview start at index 0. If there are 25 items in it, their indices range from 0 to 24. Putting 25 there would of course be invalid for index.

scudzilla 32 Junior Poster

User defined types will pass their pointers, not their contents, when appended to vectors. The memory address of a is stored at the first slot of the vector. Because the A in the vector points to the same memory location as a, the contents of the one in the vector also changes once you execute lines 23 to 27. To prevent the change, make a a new instance of class A before changing the values.

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

What's the highest row output supposed to be?

scudzilla 32 Junior Poster

Incorrect. nums.length() gives the number of characters inputted namely: 0 3 4 5 3xcomma; 7 characters in all. You might wanna use the string's Split method to get rid of the commas. Additionally, when you're adding a char to a number type, you're essentially adding the character's ascii value. Look here for ascii values of different characters.

scudzilla 32 Junior Poster

Something like this?

Selece c1.user_id, c1.company_id, c1.id from complaint3 c1, complaint3 c2 where c1.user_id = c2.user_id and c1.companyid = c2.companyid and c1.id <> c2.id group by c1.id
scudzilla 32 Junior Poster

Isn't it because you're trying to access the object's methods directly using with? Try deleting objWord in lines 3, 9, 11 and 15.

scudzilla 32 Junior Poster

Might be nasties. Read this and see if it's fixed. Upload logs if it isn't.

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

Here's my output

Polar
0 degrees: 1
45 degrees: 1.41421356237309
90 degrees: 1
135 degrees: 1.41421356237309
180 degrees: 1
225 degrees: 1.41421356237309
270 degrees: 1
315 degrees: 1.41421356237309

Cartesian
0 degrees: 1, 0
45 degrees: 1, 1
90 degrees: 0, 1
135 degrees: -1, 1
180 degrees: -1, 0
225 degrees: -1, -1
270 degrees: 0, -1
315 degrees: 1, -1

Angles increase by going counter clockwise.

scudzilla 32 Junior Poster

Note: this is pseudocode, as I'm not familiar with python

Assuming deg = degree, r = radius

def square(deg,r)
    newdeg = ((deg+45)%90-45)/180*Math.PI  # calculates the angle between the original angle and the closest axis
    newr = r/Math.cos(newdeg)
    return newr  # this is the radius for the given deg, in polar form

    # if you need cartesian coordinates instead, this converts polar to cartesian
    x = newr*Math.cos(deg/180*Math.PI)
    y = newr*Math.sin(deg/180*Math.PI)
    return x,y

This defines a square in which a circle of radius r is located.

scudzilla 32 Junior Poster

That happens to me half of the time. The other half, the tab actually closes.

scudzilla 32 Junior Poster

In line 28, why use SelectedRows property? Perhaps after a time, there is no selectedrow, therefore giving no value to the regno parameter?

scudzilla 32 Junior Poster

Oh, that's good to hear. Thanks for the response.

scudzilla 32 Junior Poster

Dani, when I use the API to enter a message into chat, the browser chat interface doesn't seem to automatically refresh.

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

It attempts to retrieve every type of control in the form and cast it into a label. If you want to retrieve only Labels, use oftype.

For Each lbl As Label in Form1.Controls.OfType(Of Label)()

scudzilla 32 Junior Poster

s1 == s2 checks whether s1 and s2 are references to the same object.

s1.equals(s2) checks whether the value of s1 is equal to the value of s2.

Use .equals

scudzilla 32 Junior Poster

That's because your code is trying to cast every type of control present in the form into a label.

Try this:

For Each ctrl As control in Form1.controls
    If TypeOf ctrl is Label then
        code
    End If
Next
scudzilla 32 Junior Poster

I don't think there's any application that can be exclusively coded in either one. Personally, I use VB.NET because I'm much more used to the Basic syntax (I coded in Basic to run microprocessors).

scudzilla 32 Junior Poster

I don't understand why they think motioninjoy is horrible >.< I've been using it for years and it's sufficient for me.

Anyway, in your device manager, can you find anything that resembles "BTH DS3 Device"?

scudzilla 32 Junior Poster

Ahh, dangerous program right there. Based on line 18, you are editing memory locations that are possibly outside of your program's allocation boundaries.

If you must use a single array for your frequency, adjust the index so that negative numbers will be included. For example, you can assign count[30] to be the counter for 0, and start incrementing the index from that.

for(i = 0; i < 59; i++)
    count[a[i]+30]++;
.
.
.
    if(count[i]==1) cout << i-30 <<"----->"<<"one time"<<endl;
    else if(count[i]!=0)
        cout<<i-30<<"----->"<<count[i]<<" times"<<endl; 

Once again, you didn't mention what integers can be stored in your matrix. For this code, an integer greater than 29 or less than -30 will probably cross the allocation boundaries.

scudzilla 32 Junior Poster

Naruto, Baby Steps, Horimiya, Ichigo, Nisekoi, Nagasarete Airantou and a few others.

scudzilla 32 Junior Poster

What're your third party drivers?

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

The question is: Do you know what numbers can be stored in your matrix?

If yes, you can, as David said, use an array to store the frequency (or two arrays, one each for negative and nonnegative integers). Simply use the integer stored in the matrix as the index in your frequency array.

If no, how do you expect to cover everything than can be stored?

scudzilla 32 Junior Poster

Are you referring to Category? Adding a new row with any string for Category works. It's still a single valued field. It's the attachments that's the multivalued field. Excluding attachments from your select query will get no errors in updating or inserting. You'll have to tackle attachments in amother way if you want to include that in the program. Unfortunately, I'm currently on the road so I can't be of much use for a few hours.

scudzilla 32 Junior Poster

When I include the Attachments column, update generates an Update error regarding a multivalued field. Excluding Attachment, the database gets updated correctly.

scudzilla 32 Junior Poster

Strange, it works for me though. Without the prefix and suffix, it gives me the same error. With the prefix and suffix, it gets updated correctly. I used your code exactly. What provider do you use for your oledb? What's your connectionstring and access version?