phorce 131 Posting Whiz in Training Featured Poster

Would it not just be as effective to write your own?

phorce 131 Posting Whiz in Training Featured Poster

Urgh,

I'm guessing on your submit page, you have something like this:

$eve = $_POST['events']; If so, can you just var_dump($eve) where $eve is the variable name. I think this is a PDO issue (I don't code in PHP no more, haven't really taken PDO on) but I believe that it's because when you're inserting, it only inserts the first word.

If the var_dump shows corretly, post the INSERT sql

phorce 131 Posting Whiz in Training Featured Poster

Okay! Try this:

echo "<option value=\"" . $row['eventName'] . "\">" . $row['eventName'] . "</option>"; 

If this doesn't work, right click on the page -> view source and post what the HTML form is saying in the <option value=>

phorce 131 Posting Whiz in Training Featured Poster

Well.. When you print eventName what is being displayed? I don't get what you mean..

phorce 131 Posting Whiz in Training Featured Poster

No problem, mark this thread as solved and give rep!! Good luck with this project!

Also, learn the difference between require and require_once

And what is the use of this: $username = $_SESSION['user']['username'];?

Peace

phorce 131 Posting Whiz in Training Featured Poster

I don't get what's going on here, dude. First off Sheffield, really? ;)

Anyway.. Back on topic: It looks like you're mixing up PDO with general mysql_* first off, mysql_* is being deprciated, hence the use of PDO

For example, you use PDO and then suddenly reach this:

$query = mysql_query("SELECT eventName from sgt")or die(mysql_error());
            while($row = mysql_fetch_array($query)) 
            {
                echo '<option value=' . $row['eventName'] . '>' . $row['eventName'] . '</option>';
            }

But surely, it would follow suite from everything else. The coding looks OK now. We sorted out the error that you are having, I personally think the fact it's not allowing you to connect to the database (on this piece of code) is because you're using PDO in the script and it does not know now which connection this referes to.

I personally think you've chosen this, as you've either ripped it off a book or the internet because you are unsure of how to display rows PDO style. I would therefore suggest trying:

$sql = 'SELECT eventName from sgt'; 
foreach($db->query($sql) as $row) {

    print $row['eventName'] . "\n";

}

Does this print the EventName? If so, then there is your problem!

Peace </3

phorce 131 Posting Whiz in Training Featured Poster

Are your connection details right? You should be able to access the database. If you're trying to run this script from your own server (i.e. on your machine) and connecting to the Universties then no, this would be a problem. Looking at your previous script though (in your other question) This was not the issue. So surely, if you can UPDATE then you can SELECT mhm. Strange. Post the full script, removing any passwords associated to your account.

Peace

phorce 131 Posting Whiz in Training Featured Poster

Then your problem is this line:

echo "<option value=\"$row['eventName']\">" $row['eventName']"</option>";

Should be:

  echo '<option value=' . $row['eventName'] . '>' . $row['eventName'] . '</option>';

If your going to code in PHP, please turn on the error handling in your .ini file, or set it. Then you'd actually be able to see these erros been given.

Peace

phorce 131 Posting Whiz in Training Featured Poster

First off, right click. Is the HTML code being populated with "eventName" if this is a no, then you should attempt to look at the querying of the database (I'm guessing that you have mysqladmin or w.e.) try and run this query within that client and see what results show up.

phorce 131 Posting Whiz in Training Featured Poster

RMS looks like the following:

142f723c1bd32e409a170fd4ab91b79d

Let's take a simple signal:

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

Then it would be the following:

rms(x) = sqrt(0^2 + ....../n)

Where n is the number of samples.

In other words, take the squared mean of the dataset, from this, find the square root. Simples

You haven't given a clear indication to what exactly you want to use with RMS for but I can make the assumtion that you need to carry out some kind of thresholding, if this is the case then:

1) Split your signal into segments
2) Calculate the RMS for each of these segments.

Here is the code written in MATLAB

function rms = quadraticMean(list)    
    rms = sqrt(mean(list.^2));
end
phorce 131 Posting Whiz in Training Featured Poster

RMS is not difficult. I don't code in Matlab anymore but can give you the algorithm and then you can code it. Or just find one online?

phorce 131 Posting Whiz in Training Featured Poster

Hey,

If you're happy for me to do so. I don't mind looking over your database, to see where you went wrong. Also, it might be a good idea to take a look at your script. If you would allow access to the server for around half an hour, that would be great. You can make a seperate user account up if you don't want the admin details. Please post back; if you're sending details, make sure they are in a PM. I am around for most of the night tonight (UK time) so I'll take a look.

phorce 131 Posting Whiz in Training Featured Poster

Have not coded PHP in so long..

<?php

ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);

$con = mysql_connect("localhost","372***", "********");
if (!$con)
  {
  die('NEIN!' . mysql_error());
  }
//Connect to DB
//(Possible offender below)
$res = mysql_query("SHOW DATABASES");

while ($row = mysql_fetch_assoc($res)) {
    echo $row['372***'] . "\n";
}
mysql_select_db(372***, $con)
or die("Lost");

echo "<table border='1'>
<tr>
<th>Employee Name</th>
<th>Employee Address</th>
</tr>";

$result = mysql_query("SELECT * FROM b8_14160309_simple*** LIMIT 1") or die (mysql_error());

$row = mysql_fetch_array($result); // I think you commented out the $result
var_dump($row[0]);

?>

This should now not display any errors. Post back

phorce 131 Posting Whiz in Training Featured Poster

Right, ok. mhm. This is really weird.

First off, attempt to do the following:

// After $result, comment the rest put this
$row = mysql_fetch_row($result);

var_dump($row[0]); // What does this give? 
phorce 131 Posting Whiz in Training Featured Poster

Please post, what the field names actually say?

phorce 131 Posting Whiz in Training Featured Poster

I can barely see that, have another one? I'm pretty sure it says 'emp_names' and not 'emp_name' am I right?

phorce 131 Posting Whiz in Training Featured Poster

Inside your table,

Are the rows emp_name / emp_address or are they named something else? Please print screen the table

phorce 131 Posting Whiz in Training Featured Poster

@Dani, using what? I'm confused by this.

phorce 131 Posting Whiz in Training Featured Poster

I'm totally in agreeance with Mike here, I've been waiting on an important email all day only to be flooded with emails from DaniWeb about questions I have no interest in.

phorce 131 Posting Whiz in Training Featured Poster

You have not given a clear indication of how you plan on doing this. I.e. what methods are you trying to extract from the signal which will allow for you to "stop playing a song".

Thinking about it; to me, you will need to have a means of training or modeling a system based on some kind of feature extraction. But, does need to be in the frequency domain? I don't know, it depends on what features you are trying to extract and why. (Not all feature extraction happens in the frequency domain, some can be in the time-domain). Going back to my original point, how are you going to train these signals?

Firstly, if I was you, I would read some papers on feature extraction within this area. For example, MFCC etc.. So what do the signals you want to investigate. Then, you need to look at a way of modelling this data, i.e. would it be better to use a Hidden Markov Model (HMM) or could you use Dynamic Time Warping (DTW).

There are lots of papers on this; read them and then more specific questions can be asked. At the minute, you're not very specific and to me, I don't think you have enough experience within this field to be able to do something like this. So, you could potentially look for other solutions (i.e. how have other people done this) and then figure where to go from there.

Hope this was somewhat helpful

phorce 131 Posting Whiz in Training Featured Poster

Turning it off. It doesn't work through web (using google mail) and it just sends me so many emails. :( Good idea tho.

phorce 131 Posting Whiz in Training Featured Poster

Yes. Of course you should get Ubuntu. I was a mac user, now have completely gone with Ubuntu/Gnome. Go for it!

phorce 131 Posting Whiz in Training Featured Poster

Hey. Welcome to DaniWeb.

May I suggest learning a different language? ;)

phorce 131 Posting Whiz in Training Featured Poster

Can you post some more code? I.e. where do you make a connection to the database? If you post back within the next 15 mins, I'll take a look - Or just write one for you to test myself!

phorce 131 Posting Whiz in Training Featured Poster

Its saying there are no records inside the table.so are there records in the table? Or the query returns NULL I would check the table. Try and screen print it to verify there are records in the table.

Peace

phorce 131 Posting Whiz in Training Featured Poster

This would actually be a good idea!

phorce 131 Posting Whiz in Training Featured Poster

Whoaa too many replies!

Good luck with your project

phorce 131 Posting Whiz in Training Featured Poster

Try:

$result = mysql_query("SELECT * FROM b8_14160309_simpleDB3 LIMIT 1") or die ("Something is wrong here", mysql_error());

OR try:

if(mysql_num_rows($result)==0)
{
   echo "Theres something wrong here";
}
phorce 131 Posting Whiz in Training Featured Poster

Hey,

Just a quick note. It's probably not effective to store the salary as a string. Why is this?

You take advantage of STL's map structure.

It works something like this:

You have two types of data (esentially) which could be represented inside a map..

std::map<string, float> employees; 

employees["Phorce"] = 150000;
employees["Foo"]    = 10.00;

Now let's say you wanted to find a record, and, how much they earn. (Using C++11 but I'm sure there are older versions that are very similar to this):

auto it = employees.find("Phorce");

for (it != employees.end()) 
    std::cout << "Phorce" << it->second << "\n";

// Would/should display the slary for Phorce

Notes about your code:

 //constructor
 user employeeDetails(userName,
                             salary
                             );

This is not a constructor. This is initialising an object of the contstructor.

Your current method for searching looks through each iteration once, until it's found the match. This approach might not be ideal, since, if you have a large collection of data then it will become slower and sluggy.

Again, why re-invent the wheel? STL has a function which already handles searching; since you are using a vector it could look something like this:

#include <algorithm>

if (std::find(employees.begin(), employees.end(), "Phorce") != employees.end())
{
   // Found
}

Hope this helps some.

phorce 131 Posting Whiz in Training Featured Poster

What? No. This is not how OOP works. Why are you defining your class implementation in main.cpp? This should be inside of the .cpp associated with your class file!

Why do you have a empty/initial constructor that initialises some strings? Look at your code, get it to work as just one main file before moving onto more advanced concepts as OO.

phorce 131 Posting Whiz in Training Featured Poster

What exactly do you want to do with these signals? How do you think an FFT algorithm would fit into this? It's a pretty hard question; when you give so little about what it is you're trying to do. Please expand more.

phorce 131 Posting Whiz in Training Featured Poster

I did not just read..

write a function named, smallestValue, that accepts five integers and return the smallest integer accepted.( just write a function)

Please tell me this is not given to you as a home work assignment?

phorce 131 Posting Whiz in Training Featured Poster

Should be something like the following:

int foo(double a) {

    return a;
}

std::function<void(double)> call_foo = &foo;
phorce 131 Posting Whiz in Training Featured Poster

First of all.. What does the file contain? I have no experience in this file format, but, I'm sure there will be some tutorials out there on the header and how to handle the format. If it's numerical, 8bit, 16bit, etc.. You have to handle these. Read the file into a char array and then try conversion methods.

phorce 131 Posting Whiz in Training Featured Poster

You are kind of doing it wrong.. What you want to do, is create an Array of objects, the size of this array can then be determined at run-time.. Something like the following:

#include <iostream>
using namespace std;

class Foo {

    public:
        static int count; 
        Foo() {

        }

        Foo(int i) {
            std::cout << "I am object no: " << count << std::endl;
            count++;    
        }


};  

int Foo::count = 0; 

int main() {
    // your code goes here
    std::size_t number; 
    std::cout << "Enter the number of accounts you want to create: ";
    std::cin >> number; 

    Foo* f[number];

    for(unsigned i=0; (i < 10); i++)
    {
        f[i] = new Foo(i);
    }
    return 0;
}

I am object no: 0
I am object no: 1
I am object no: 2
I am object no: 3
I am object no: 4
I am object no: 5
I am object no: 6
I am object no: 7
I am object no: 8

http://ideone.com/svNp9S
I am object no: 9

phorce 131 Posting Whiz in Training Featured Poster

Why is this title in another language and the post is written in English?

Also, on topic, what have you tried yourself?

phorce 131 Posting Whiz in Training Featured Poster

Do you really need that many classes? Will these classes get used more than once? For example, the class "ProgressBar" what is this for?

phorce 131 Posting Whiz in Training Featured Poster

Hey DaniWeb Never fear, Phorce is here!

I've completely stopped getting emails from you guys when a watched article has been read. I've clicked "Watch article" and everything but still nothing.. Checked my spam folder, nothing.

Anyone else facing this issue?

phorce 131 Posting Whiz in Training Featured Poster

Could you not do something like:

$action = $_GET['action']; // assume that action.php?action=edit

switch ($action) {

        case "Edit":
            echo "EDIT STUFF HERE";
            break;

        case "update":

            echo "Update here";
            break;
        /*.....*/

        default: 
        echo "Default";
    }    
phorce 131 Posting Whiz in Training Featured Poster

I'm a bit confused regarding the actual question you're trying to ask, so, here's a solution to the problem of passing an array to a function:

// 1D representation
        void showFunction(int* arrayValues, int SIZE)
        {
            for(unsigned i=0; (i < SIZE); i++)
            {
                std::cout << arrayValues[i] << std::endl;
            }
        }

Here you have a 1D representation of how you would display the data in a 1D array, although, I would not do this in a class member function, as it's not really wise to physically have cout ops inside a class member function.

Here is a 2D representation:

// 2D representation
        void showFunction(int values[][5], int SIZE) 
        {
            for(unsigned i=0; (i < 2); i++)
            {
                for(unsigned j=0; (j < 5); j++)
                {
                    std::cout << values[i][j] << std::endl;
                }
            }
        }

Where 5 is the size of the array etc.. I don't really agree with 2D arrays set out like this, since, in memory, a 2D array is infact stored as a 1D block of memory, you just access it differently, so, for example, the "1D representation" example I gave in this example, could be used for 2D, just splitting or writing the clause where you know you are going to seperate the data is required.

Here is a messy implementation, or, example of the two functions uses:

// 1D
    int values[] = {1, 2, 3, 4, 5};
    const int SIZE = 5;

    // 2D
    int values2D[][5] = {
        {1, 2, 3, 4, 5},
        {1, 2, 3, 4, …
phorce 131 Posting Whiz in Training Featured Poster

Try adding -std=c++0x as sometimes, this can cause problems depending on the compiler. What is the operating system you're currently working on?

phorce 131 Posting Whiz in Training Featured Poster

Just throwing it out there, but did you add -std=c++0x?

phorce 131 Posting Whiz in Training Featured Poster

What do the values represent? I.e. P, r, etc.. I'm guessing n is the current position in the matrix?

phorce 131 Posting Whiz in Training Featured Poster

Oh. So you are actually compiling through XCode? Do you have the command line tools installed? If so, could you not just attempt to link using GCC (g++) so for example:

Check this link

Might help you. Other than that, I'm stumped since I've never used the library :(

phorce 131 Posting Whiz in Training Featured Poster

Just a quick question..

Have you installed RE2 correctly? Also, are you linking it correctly when you compile this code? I.e. show what line you use when compiling g++ blah it sounds to me that you're not linking the library properly.

phorce 131 Posting Whiz in Training Featured Poster

Don't use mysql_* or session_register

phorce 131 Posting Whiz in Training Featured Poster

On a side note: The link that @iwavetostars mentioned is a really good read; I actually want that book as a reference.

phorce 131 Posting Whiz in Training Featured Poster

Pick a project that is interesting to you. I.e. At my University, I've just been assigned to do some research based work with the Leap Motion sensors (I don't know if you've come across those) and instead of using C++ (What I am familiar with) I've chosen to use Python. Have I gone and research and read through 100's of books and documentation regarding it? No. I've sat down, used my brain and realised the things that I picked up in C++ are very similar to those in Python and Googled what I needed.

phorce 131 Posting Whiz in Training Featured Poster

Let me just ask you: Is there really any point in sitting down and learning Python, when you already know C/C++? Let's look at this logically, from gaining knowlege in C/C++ you should have an understanding of syntax and how programming logic works. So, would you benefit from sitting down and actually reading: if x is 10: blah blah - Probably not! Learning the basic structure, is ok. But from there, you should pick a project to do and start from there - Thus meaning you gain quick knowlege and your understanding improves.

phorce 131 Posting Whiz in Training Featured Poster

Why do you want to do this? I don't get the point??