phorce 131

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

@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

@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

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

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

phorce 131

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

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

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

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

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

phorce 131

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

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

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

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

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

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, 5}
    };

    Foo f;

    f.showFunction(values, ...

phorce 131

Hello,

ld, but I need to start somewhere and make some visible results on my projects.

Maybe you should assess what your "projects" are and then make the decision on the language to choose?

phorce 131

The style and syntax is horribly wrong. You should work on this, here:

Q: Why do you need to include the .cpp to this? It's just.. not needed.

Here's an alternative:

Stuff.h

#include <string>

bool Correct_Parent(std::string x)
{
    int p_Left_Counter  = 0;
    int p_Right_Counter = 0;
    for(unsigned int c = 0; c < x.size(); c++)
    {
        if(x[c] == '(' )
            p_Left_Counter++;
        else
        if(x[c] == ')' )
            p_Right_Counter++;
    }
    if( p_Left_Counter != 0 && p_Right_Counter != 0)
        if(p_Left_Counter == p_Right_Counter)
            return(true);
    return(false);
}

You don't need to request the whole of the std namespace: using namespace std when you are only using a string.. This is bad.

Then your main would be:

main.cpp

#include <iostream>
#include "Stuff.h"

using namespace std; // Do you really need this?

int main()
{
    //...
}

This should work. I'm not at a compiler though, so, I haven't checked.

younes.keraressi commented: yes sorry about syntax, yes i need using namespace std to cin and cout +0

phorce 131

@cam - No, this has to be outside of the class definition.
You're delcaring a static reference, the class has to know where it is initialised.

phorce 131

This question cannot be answered; since, it depends purely on the programmer and their preferences. (Bit like the Mac vs Windows arguement) each have their own strenths and own weaknesses and based on those, you should make your own decision.

phorce 131

No.. A 2D array will still allocate 1D block of memory.. It's just how you access this.. For example:

    rows = 13;
    cols = 10;
    int* values;
    values = new int[rows*cols];

    for(unsigned i=0; (i < rows); i++)
    {
        for(unsigned j=0; (j < cols); j++)
        {
            values[i*cols+j] = 0.0;
        }
    }

We are still using a 1D block of memory, however, accessing this 1D of memory as a 2D (array).. Does this make sense/

phorce 131

I'm sure many will agree, facial recognition is a hard task to acomplish; particularly in C++ as this (without any libraries) would require you to build such from the ground upwards in order to give come close to an expected outcome, which is why most researchers use Matlab etc..

That being said, there is a very good, and useful library ouut there called openCV: Here which will give you the toolset in order to complete this. The good thing about openCV is it is open source, and, thus means that there are 100's of documentation centered on Facial Recognition and image recognition etc.. Take a look at this: Here as an example.

Hope this helps

iamthwee commented: Yup +14

phorce 131

@mmcdonald

How would this work:

<?php echo number_format($row_total['sub_total'], 2, '.', '')]; ?>

Where did the last ] come from?

It should be:

<?php echo number_format($row_total['sub_total'], 2, '.', ''); ?>

Would work, I guess!

=)

phorce 131

No problem :) Don't forget to leave people rep

phorce 131

After Message is displayed "Database Successfully updated!" for it to return back to the html form it was originally on?

Suppose you could use: header("Location: form.html");

Also a tutorial somewhere on how to handle if Email and Code is UNIQUE and same values have already been entered it displays an error message specific to Email or Code?

You should be able to find these, doing a DaniWeb search, and/or a good search.. But I'll write some functions to get you started..

    function checkEmail($email1, $email2) {

        return (bool) ($email1 == $email2) ? 'true' : 'false';
    }   

    function checkRex($email)
    {
        return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
    }

We can use these as follows:

// assume you've asked the person to confirm their email address:

$Email;
$Emailconfirm;

if(!checkEmail($Email, $Emailconfirm){
 die("Your emails do not match");
}

// function to check if email is valid

if(!checkRex($Email))
{
   die("Your email is not valid");
}

Or to check if the email already exists:

    function checkExists($email)
    {
        // sql details      
        $query = "SELECT email FROM users WHERE email='$email'";
        $result = mysql_query($query);
        if(mysql_affected_rows($result) == 1)
        {
            return (bool) true;
        }else{
            return (bool) false;
        }
    }

Hope this helps

phorce 131

First off, it's wrong.

It should be:

$id = isset($Telephone) ? trim($Telephone) : " ";

The expression is a Ternary logic operator and it will assign $id to whatever is set. So it's just like doing the following:

if(isset($Telephone)
{
   $id = $Telephone;
}else{
  $id = "";
}

Hope this helps

EDIT:

So in theory what we do is:

1) Initialise a variable "$id" to hold the value passed through $_POST['Telephone'];

2) Using the tinary operator, assign $id with a value based on some logic: `if(isset($Telephone) // is there a vaue ? // yes there is $Telephone) // return $Telephone : // no there isn't a value, so 'id' gets stored as null || empty

phorce 131

It looks like it doesn't know what $Telephone = $_POST['Telephone']; is since you are not posting Telephone you are posting: Phone so do this:

$Telephone = $_POST['Telephone'];
    $id=isset($_POST['$Telephone']) ? trim($_POST["$Telephone"]) : "";

// has to be :

$Telephone = $_POST['Phone'];
    $id=isset($Telephone) ? trim($Telephone) : "";

This should work

phorce 131

@Andy - If we pass by reference, we get the actual memory allocations and not the value. Thus meaning we can ensure speed as well as the fact if the values have to be changed in any way.. Then this will be done in direct memory.

phorce 131

You are missing the ; off your function prototypes. The ones you have, should work with your compiler..

You could, however, do the following:

void Scanned(std::ifstream& ifp,int i);

but make sure you include <fstream>

Your struct seems fine, is there a reason why you're not using classes - Just out of interest?

You shouldn't really need the typedef and would be just the following:

struct Checker
{
  int age;
  char name[20];
  int  roll_call;
};

Also, in the following: Checker pass in the arrays as references: int Checker(char *s,char *u)

Hope this helps.

phorce 131

university they would briefly cover each of these fields.

This totally depends on the University and/or the choice of course you study. Most are programming based (in the UK) but it's very unlikly (unless you study a Games related course) that they will cover "Graphics Porgramming" however, Web Developer and Mobile Development are becoming more dominant in the market so these would be covered.

So what I'm trying to ask is, would I be at least equally competent to a university graduate?

Universties "teach" you how to research independantly and within a group. I wouldn't go to University and expect them to teach you EVERYTHING there is to know about programming/languages/compilers/operating systems/algorithms etc.. So, it depends on your personal prospective; if you decide not to choose a University course, and gain experience and knowlege then I doubt that will go against you when applying for jobs, since, most graduate jobs these days require experience over a "piece of paper" so it all depends.

With regards to your first post:

code a basic operating system

Why? What would be the point in this? The latter, getting involved with the Linux community and helping developing something - This would be ideal.. Not creating your own operating system.

If I learn several programming langauges, assembly, complier design, software architecture, design patterns, to write clean code, electronics, some common libraries, data structures and algorithms, networking, database managamenet systems, front end and back end development, and some other core computer science ...