phorce 131 Posting Whiz in Training Featured Poster

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 Featured Poster

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?

phorce 131 Posting Whiz in Training Featured Poster

Have you made sure that the file is being included?

phorce 131 Posting Whiz in Training Featured Poster

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
phorce 131 Posting Whiz in Training Featured Poster

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?

phorce 131 Posting Whiz in Training Featured Poster

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.

phorce 131 Posting Whiz in Training Featured Poster

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.

phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster

@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.

phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster

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 …

phorce 131 Posting Whiz in Training Featured Poster

You need to post this in the forum "PHP"

phorce 131 Posting Whiz in Training Featured Poster

@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
phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster

$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

phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster
phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster

Have you tried:

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

?

phorce 131 Posting Whiz in Training Featured Poster

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..

phorce 131 Posting Whiz in Training Featured Poster

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 …

phorce 131 Posting Whiz in Training Featured Poster

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!!"
phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster

Try this:

$add=mysql_query("INSERT INTO contact VALUES ('','$salutation','$fname','$lname','$houseone','$housetwo','$housethree',$tel','$off')") or die(mysql_error());
phorce 131 Posting Whiz in Training Featured Poster

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.

phorce 131 Posting Whiz in Training Featured Poster

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

phorce 131 Posting Whiz in Training Featured Poster

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?

phorce 131 Posting Whiz in Training Featured Poster

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.

phorce 131 Posting Whiz in Training Featured Poster

Hey,

No-one would give you their email and you sending them across any source code. You haven't answered the right questions; or, given any indication in your post. Why doesn't it compile? There must be a reason, or, give an error (This is why error messages are generated because in most cases, you can tackle the problem just by reading through the error messages)

Post your error messages here and someone MAY be able to identify what the problem is, additionally, you can submit any code which might be causing the problem.

phorce 131 Posting Whiz in Training Featured Poster

You have just copied the code from somewhere in a hope that it will work? This is a very bad way to solve a problem, and, this has obviously been shown here.

From what I can see, skim reading of the code, you seem to have a mixture of C and C++ in here. Not great, but, also not the end of the world, providing you handle this correctly..

What I suggest that you do is, firstly sit down and THINK about what you want to do. Get a pen and piece of paper, perform some steps or calculations on what it is that you're trying to do and then formulate how this will be put i nto code.

phorce 131 Posting Whiz in Training Featured Poster

I have no idea what you are trying to do, or, what you are trying to convey in this post.

Are you trying to calculate the velocity, or change in time on 2 vectors (matrices)?

phorce 131 Posting Whiz in Training Featured Poster

What are you actually simulating though? This would help

phorce 131 Posting Whiz in Training Featured Poster

Happy birthday :) hope all your wishes cone true; celebrate well!

phorce 131 Posting Whiz in Training Featured Poster

Might be asking a stupid question here, but, why is this in server-side? Since, I'm pretty sure it goes off the time and date set in the server, over what is on the local machine. Since it's a day out, probably your problem is that you're not setting a default timezone, whereas the website you gave MAY be using Javascript which is a client-side and reads from your actual machine. I'd check this.

phorce 131 Posting Whiz in Training Featured Poster

First off, please note that mysql_* functions are soon to be removed from the standards.

To answer your question, you can do the following:

<?php

    $email = $_SESSION['email'];

    $query = "SELECT * FROM tbl_student_master WHERE email='$email'";
    $result = mysql_query($query) or die(mysql_error());

Or just the following:

<?php

    $email = $_SESSION['enail'];

    $query = "SELECT * FROM tbl_student_master WHERE email='$_SESSION[email]'";
    $result = mysql_query($query) or die(mysql_error());
phorce 131 Posting Whiz in Training Featured Poster

It really depends on the things that you are wanting to do. Programming in general is a very broad subject.

If you are into web development then it might be an idea to choose something small, such as HTML.before tackling more dynamic and sophisticated languages such as PHP.

If your into hardware languages, complex systems that power intensive calculations and processes then might be an idea to take the C/C++ line.

I personally find that to get a grasp on both types of environments, python is an ideal candidate. The syntax is also very simple to understand and get to terms with it as this is one of the main reasons the language is being taught to children. Once again, it totally depends on your interests

One thing I do suggest, many will not agree with me.. Do not be one of those who state "I want to know every language" because it will just be like chasing the rainbow (so to speak!) The chances of knowing EVERY languag even if starting at the age of 2 would not be possible, IMO. Things in this industry change daily.

Also when it comes to learning; the saying "don't re-invent the wheel", which, to some extent is true. Don't do something that has already been done, unless you want to see the inner workings of it (come on, how many times have you took or wanted to take your PC apart)? Same principle.

Truth is, you can learn more about programming by …

phorce 131 Posting Whiz in Training Featured Poster

I'm confused?

phorce 131 Posting Whiz in Training Featured Poster

What is it that you are trying to do? If you are trying to square each element in the vector/array then it would be y[i]*y[I] but I doubt that's your problem but I don't exactly know what it is you want to do so can you be more specific?

phorce 131 Posting Whiz in Training Featured Poster

Assume that I have a vector:

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

What I need to do is split this vector into block sizes of blocksize with an overlap

blocksize = 4

overlap = 2

The result, would be a 2D vector with size 4 containing 6 values.

x[0] = [1, 3, 5, 7, 9, 11]

x[1] = [ 2 4 6 8 10 12]

....

I have tried to implement this with the following functions:

std::vector<std::vector<double> > stride_windows(std::vector<double> &data, std::size_t 
NFFT, std::size_t overlap)
{
    std::vector<std::vector<double> > blocks(NFFT);   

    for(unsigned i=0; (i < data.size()); i++)
    {
        blocks[i].resize(NFFT+overlap);
        for(unsigned j=0; (j < blocks[i].size()); j++)
        {
            std::cout << data[i*overlap+j] << std::endl;
        }
    }
}

This is wrong, and, segments.

std::vector<std::vector<double> > frame(std::vector<double> &signal, int N, int M)
{
         unsigned int n = signal.size();
         unsigned int num_blocks = n / N;


         unsigned int maxblockstart = n - N;
         unsigned int lastblockstart = maxblockstart - (maxblockstart % M);
         unsigned int numbblocks = (lastblockstart)/M + 1;

         std::vector<std::vector<double> > blocked(numbblocks);

         for(unsigned i=0; (i < numbblocks); i++)
         {
                 blocked[i].resize(N);

             for(int j=0; (j < N); j++)
            {
                blocked[i][j] = signal[i*M+j];
            }
        }

         return blocked;
}

I wrote this function, thinking that it did the above, however, it will just store:

X[0] = 1, 2, 3, 4

x[1] = 3, 4, 5, 6

.....

Could anyone please explain how I would go about modifying the above function to allow for skips by overlap to …

phorce 131 Posting Whiz in Training Featured Poster

Going with @Jorge here, let's say you had just a service where you can only sign in using your username, atleast have an option where the users can enter some information to retrieve what their username is. I.e. "I've forgotten my username"

phorce 131 Posting Whiz in Training Featured Poster

@Abdul - I find it really surprising that you have managed to "dig" up a post from 6 years ago

phorce 131 Posting Whiz in Training Featured Poster

This is always a good project (http://en.wikipedia.org/wiki/P_%3D_NP_problem)

.... Joke. @dean makes some valid points ;D

phorce 131 Posting Whiz in Training Featured Poster

What do you mean by "Pin"?

phorce 131 Posting Whiz in Training Featured Poster

To me, it appears that you are passing in too many variables. What do these do?

Another thing:

 //check input is not empty
    if (String == "") {
        return 0;
    }

Here, in your comments you say "check if a string is not empty" but, in actual fact, you're checking to see if a string is empty..

Why create a variable for slen? your function could just have:

return(String.length())

I really don't know what this function does, to me, for some strange reason, it performs so many different tasks, yet only returns the length of a string. Is this really accurate?

phorce 131 Posting Whiz in Training Featured Poster

Yeah, Matlab provides the full source code as well as the algorithms/equations used for FFT.

Open('fft')

edit fft

phorce 131 Posting Whiz in Training Featured Poster

Then, what is the error?

phorce 131 Posting Whiz in Training Featured Poster

@Mike, I kind of disagree with your last post, slightly. I don't think installing Ubuntu on a Virtual box is more effective, since it will be more slower. And, usually, when you have a Mac you tend to have a wireless keyboard + mouse, which can be an issue.

That being said, you can duel boot and select which partition you want at start up!

phorce 131 Posting Whiz in Training Featured Poster

I don't think your query is valid: $query = "SELECT DVD ID, Name Of the DVD, Quantity FROM DVD"; looks too plain english.