phorce 131 Posting Whiz in Training

I'm having the following difficultly:

I have a table rates which contains the follow:

-> id 
-> rate_from
-> rate_to 
-> price 

A user can have many rates, and for an example:

between 0 - 10 hours the user charges 10.00 an hour
between 10 - 100 hours the user charges 20.00 an hour

What I want to do is calculate, let's say that the person has worked 40 hours then it would be the following (10 * 10 + 30 * 20)

But the issue is, how can I achieve this using PHP? They could potentially have worked 48.10 for example.

phorce 131 Posting Whiz in Training

Hi all,

I think I might have missed something, I have been away for sometime. I was visiting the site and noticed that I had access to area 51. But I don't seem to recall having any of the privileges mentioned in the description.

Is this an error or has the rules changed to whom can access Area 51?

Have you made sure that the file is being included?

You have not declared the method prototype correctly in your class.

static std::map<std::pair<u32, u32>, CreateSessInfo> m_mSessionId2CCRNum2DefaultBearerId;

Shoudl be:

static std::map<std::pair<u32, u32>, CreateSessInfo> m_mSessionId2CCRNum2DefaultBearerId()
{
    // Logic here

    return map; 

}

Then you can access it as:

Foo::m_mSessionId2CCRNum2DefaultBearerId();

Here, I did a similar example: http://ideone.com/NelSt9 no logic is there, but, I hope it gives you an understanding of where you went wrong.

EDIT:

Just realised what you were attempting, so, @NathanOliver answer is more accurate.

rubberman commented: Good - give credit where credit is due! :-) +12

Your problem does not seem like it is on line "4", more of the line above, below. You have not specified the error, what does the error say is the problem?

Assuming that it is what I think you are doing:

int** DATA = new int*[10]; // This has now got 10x0

This initialises a 2D array called DATA with 10 columns.

You will need to therefore set the rows when you are iterating through the array. Each row (0.....9) will have a row.

Something like this:

for(unsigned i=0; (i < 10); i++)
    {
        DATA[i] = new int[5];

        for(unsigned j=0; (j < 5); j++)
        {
            DATA[i][j] = i*j; 

            std::cout << DATA[i][j] << ' ';
        }
        std::cout << std::endl;
    }

Notice how I have a for loop, which is iterating through 10 times 0...9 and DATA is initalised as having 10 columns. I can therefore set each of these columns DATA[i...j] (0-9) to be of size 5 (in this instance). Then I can set the values, but, also I can output the values. An example: Ideone

I hope that this helps.

Well, this function:

bool (LineSegment &ls) {
    int dist;
    ls.p1 = ls.p1 + dist;
    ls.p2 = ls.p2 + dist;
  }

If you look at a method, in terms of some pseudocode:

function [type] [name] (parameters)
[
//... implementation

return [typy]

]

Therefore, you can think of it like this:

bool method_name (LineSegment &ls){

  //... implementation 

  return true; 
}

Just remember where to put your return, in your code, it's in the wrong place. Needs to be in the brackets.

Please define "Rubbish" in terms of what you actually get, please.

No, you would just create a rand for the users, you would input the user:

int player[5]; 

for(int i=0; (i < 5); i++)
{
   std::cout << "Please enter number" << i;
   cin >> player[i];
}

then you would carry out the comparision.

Hope this helps

@mike
I hate Hidden Markov models, but, glad you brought it up.. Surely, the Hidden Markov model (in any case) is predicting the next step, so taking the observations, from the user.. I don't think your example is much of a problem in HMM's but more in cross-correlation techniques, "I'm hungry", "Resturant" whereas the HMM builds a probablistic model of such a representation and uses (viterbi) to decode the most likely path and thus provides a probability to the next stage. Correct me if I'm wrong. Nice post though. +1

I know, this is mostly handled via hidden Markov models (HMM), where the "state" of the system would be the goals or intentions of the agent (e.g., human) that is being observed, and every interaction with that agent serves to clarify what those are. For example, if you tell Siri "I'm hungry", it might start to infer that you might be looking for a restaurant, and might ask for clarification like "do you want me to locate a restaurant", and so on.

Hey, what the problem is asking you is to count the total number of times an element exists inside an array.

Assume the following:

A = [1, 2, 3, 4]
B = [2, 1, 2, 4]

Then you can do the following:

AϵB

This is going to either give you true or false..

Because 2 in B exists in A, 1 exists... Therefore, only having one array does not make sense, there has to be two arrays, one containing the winning results and another containing the user's results. Apply this, therefore:

pseudocode

int count = 0; 
foreach(element in A)
{
   int c = element;
   if(c == element)
   {
      counts++; 
   }
}

Sorry, I could not give you the answer. But, have a go and let me know if you struggle with anything

Hello,

Ateficial intelligence is a broad scope, and does not just depend on the algorithms and software based solutions as you're pointint out. There are other aspects, in terms of Robotics which contains primarly a hardware approach to solving these tasks. Understanding robotics, for example, does not really depend on understanding the software (Although, to some extent) but it's mainly in hardware and building systems to interact with the software.

I know the real world present artificial intelligence system examples like the Google Search Engine, Siri, etc. All of them are, according to my knowledge, totally software based.

Well no, not really. They all depend on the hardware to some extent. I.e. Let's look at Sirir, your device must have a way to covert the analog signal to digital signal, right? It must also store the values somewhere, right?

If hardware is also required then which thing or component or you can say which thing(s) make the AI system hardware different from the ordinary hardware used in daily computing computers

This question is too broad. You cannot assume that there is a standard what you need, and, this fits all. It just cannot work like this. It totally deponds on the problem that you're trying to face, for example, if your problem is centered around human computer interaction, then, the most likely hardware that you will need is a robot which will be human size (Although, this is not really standard) but it would need to interact with ...

You need to post this in the forum "PHP"

@down-voter

Why did my post get downvoted for suggesting an improvement? I.e.

$query="INSERT INTO 'users' (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email` ,`confirmemail`) VALUES ('$firstname', '$lastname', '$username', '$password', '$confirmpassword', '$email' , '$confirmemail')";

Notice how the single string quotes are wrong? Don't get click happy and read what the suggestion is before you go ahead and just down-vote. Tyvm

iamthwee commented: still love ya no homo +14

Please do not create a new topic with the same question; this can be classed as spam and your question will be deleted.

What you are doing here is using the same array, which, in tern most likely segment and thus time out.

Try, something like the following:

  for(int n = 0; n < num_samples; n++) //where n is the step |start of for loop
  {
     int fr = 523;          //Frequency A  
     data[n] = amp*sin(2*pi*fr*n/fs);  
     cout << n << "\t" << data <<"\n"; 

     int fre = 587;       //Frequency B  
     data[n] = amp*sin(2*pi*fre*n/fs);  
     cout << n << "\t" << data <<"\n"; 
   }

But, even this would not work. Why won't it work? Simply because your structure has to be like this:

|one tone| -> -> -> |two tone|

If you take a look at the code sample that I give you, using vectors, I created 2 vectors which stored the two tones, then, having a separate vector which concatenated the data series. This is what you need to use.

My best advice would be to sit down and really think about this problem; what you're trying to do in C++ is not for the average user, you should have atleast some experience in arrays, and, data structure before you begin tackling this problem.

P.S. num_samples will need to be double the size of the array that you have.. If size is currently 512, it would be 512*512

$connection = mysqli_connect("host", "username", "password", "mybd") or die("Error!!");

Try this. You need to connect to a database, before you can do anything. The rest of your code looks to be working fine now. Just need to give the query a valid connection.

peace

So, as I said in my first post. If you increase the total number of n values, then, you would therefore increase the total size of the audio file.. n < 256 > 1024 That being said. You could (as a test) have two different loops that write to two different arrays and then concatenate these two arrays before writing them to the .wav file.

Let me know how you get on

Yes lol. You need to give it the connection statement. Try this. http://uk1.php.net/mysqli_connect

Well, in this statement: $result = mysqli_query($connection,$query); where do you define $connection?

Have you tried:

$query="INSERT INTO users ('firstname', 'lastname', 'username', 'confirmusername', 'password', 'confirmpassword', 'email' ,'confirmemail') VALUES ('$firstname', '$lastname', '$username', '$password', '$confirmpassword', '$email' , '$confirmemail')";

?

What do you mean by "Tune", what it looks like you're doing is creating a sine wave at a particular frequency Htz. Where do you declae the sampling rate?

If you're talking about creating a "tune" in terms of a synthesizer then this is a lot more complex and you should probably begin somewhere small if this is your first time in this.

P.s You also haven't given your variables amp, fs etc..

If you want to change the length, increase num_samples if you want to change the frequency, change the frequency and so on and so on..

First off, your question is quite confusing. I can't gather what it is what you're trying to do, let me try with a different example, see if it makes sense to what I think they are wanting you to do.

Let's assume that you have a Person, each person therefore, has a: Name, age, nationality.. Defined below:

class Person
{
    public:

        Person()
        {
            // default
        }

        Person(std::string name, int age, std::string nation)
        {
            this->theName = name;
            this->theNation = nation;
            this->age = age;
        }

    protected:

        std::string theName; 
        std::string theNation;
        int age;
};

So, far we have created the base class. We now introduce inheritence, let's say that you now have a "Student", well a "Student" shares all the characteristics as a person and therefore you can inherit from this:

class Student : public Person {

    public:

       Student() { } // default 

       Student(std::string theName, int theAge, std::string nation, int num)
          : Person(theName, theAge, nation)
       {
          // now we can do this:
          this->theNum = num;

       }

    protected:

       int theNum;

}

Therefore, when we are creating objects, we no longer have to look at the "Person" class.. We can just do the following:

Student s("Phorce", 10, "British", "00001");

If we had a method in the "Person" called getName we could do the following:

std::string returnName()
{
    return this->theName;
}

We can access it by std::cout << s.returnName() note how we did not define this in the Student class?

This can relate to your problem, you can try and figure it out. I'm not too ...

I'll give you an idea:

initialise (char) c; 

do 
 -> input c 

 -> while (c IS NOT 'a', OR 'b', OR 'c')

 -> print "Yes I did it!!"

I'm sure I've seen someone else ask this question on here, I might be wrong! Please show that you have at least tried :P

Try this:

$add=mysql_query("INSERT INTO contact VALUES ('','$salutation','$fname','$lname','$houseone','$housetwo','$housethree',$tel','$off')") or die(mysql_error());

You still don't explain what the question is. What is wrong with this? What do you want to do.. We cannot help you, if we don't know what it is you're trying to do.

What is the question? Your conditional statement is wrong. Look on line 15, why would you need ;?

Because not many people have access to this library, please could you specify some expected input and outputs?

Also, what is the data type of MInput?

I believe, from what I can see is that the validation requires a . followed by between two or three characters (\.[a-z]{2,3}) so email addresses like: test1@gmail.com would valid true, whereas email addresses containing a . with only one character, would throw up an error.

There are some pre-built functions: http://www.php.net/manual/en/filter.examples.validation.php which would filter this information for you.

Hope this answers your question, slightly.